Skip to content

Commit

Permalink
Merge branch 'js/help-commands-verbose-by-default-fix' into maint
Browse files Browse the repository at this point in the history
"git help -a" did not work well when an overly long alias is
defined, which has been corrected.

* js/help-commands-verbose-by-default-fix:
  help -a: handle aliases with long names gracefully
  help.h: fix coding style
  • Loading branch information
gitster committed Dec 15, 2018
2 parents bf29f07 + 1c4b985 commit 916f56d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion help.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ static void print_command_list(const struct cmdname_help *cmds,

for (i = 0; cmds[i].name; i++) {
if (cmds[i].category & mask) {
size_t len = strlen(cmds[i].name);
printf(" %s ", cmds[i].name);
mput_char(' ', longest - strlen(cmds[i].name));
mput_char(' ', longest > len ? longest - len : 1);
puts(_(cmds[i].help));
}
}
Expand Down Expand Up @@ -526,6 +527,13 @@ void list_all_cmds_help(void)

git_config(get_alias, &alias_list);
string_list_sort(&alias_list);

for (i = 0; i < alias_list.nr; i++) {
size_t len = strlen(alias_list.items[i].string);
if (longest < len)
longest = len;
}

if (alias_list.nr) {
printf("\n%s\n", _("Command aliases"));
ALLOC_ARRAY(aliases, alias_list.nr + 1);
Expand Down
2 changes: 1 addition & 1 deletion help.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct cmdnames {

static inline void mput_char(char c, unsigned int num)
{
while(num--)
while (num--)
putchar(c);
}

Expand Down

0 comments on commit 916f56d

Please sign in to comment.