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>

Nguyễn Thái Ngọc Duy committed Jan 31, 2019 at 16:23 UTC 6195a76da4b0c58b320d8f7c3485ee51b0f2a8e6
1 file changed +2 -1
help.c
+2 -1
@@ -85,7 +85,8 @@ static void print_command_list(const struct cmdname_help *cmds,
85 if (cmds[i].category & mask) {
86 size_t len = strlen(cmds[i].name);
87 printf(" %s ", cmds[i].name);
88 - mput_char(' ', longest > len ? longest - len : 1);
88 + if (longest > len)
89 + mput_char(' ', longest - len);
90 puts(_(cmds[i].help));
91 }
92 }