summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-01-31 09:23:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-31 23:27:35 (GMT)
commit6195a76da4b0c58b320d8f7c3485ee51b0f2a8e6 (patch)
tree55ae50b400a061caeb0b43269a13ad89be37c382 /help.c
parent0d0ac3826a3bbb9247e39e12623bbcfdd722f24c (diff)
downloadgit-6195a76da4b0c58b320d8f7c3485ee51b0f2a8e6.zip
git-6195a76da4b0c58b320d8f7c3485ee51b0f2a8e6.tar.gz
git-6195a76da4b0c58b320d8f7c3485ee51b0f2a8e6.tar.bz2
help: align the longest command in the command listing
"longest" is used to determine how many extra spaces we need to print to keep the command description aligned. For the longest command, we should print no extra space instead of one, or we'll get unaligned output like this (notice the "checkout" line): grow, mark and tweak your common history branch List, create, or delete branches checkout Switch branches or restore working tree files commit Record changes to the repository diff Show changes between commits, commit and ... merge Join two or more development histories together rebase Reapply commits on top of another base tip tag Create, list, delete or verify a tag ... Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.c')
-rw-r--r--help.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/help.c b/help.c
index ff05fd2..520c908 100644
--- a/help.c
+++ b/help.c
@@ -85,7 +85,8 @@ static void print_command_list(const struct cmdname_help *cmds,
if (cmds[i].category & mask) {
size_t len = strlen(cmds[i].name);
printf(" %s ", cmds[i].name);
- mput_char(' ', longest > len ? longest - len : 1);
+ if (longest > len)
+ mput_char(' ', longest - len);
puts(_(cmds[i].help));
}
}