index-pack: correct --keep[=<msg>]
[gitweb.git] / help.c
diff --git a/help.c b/help.c
index df7d16d7ce52ce9b9f274db92b24aa64bac56ebf..97567c452364838ea720fc8f61d2e9ab96304613 100644 (file)
--- a/help.c
+++ b/help.c
@@ -78,8 +78,7 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
        cmds->cnt = cj;
 }
 
-static void pretty_print_string_list(struct cmdnames *cmds,
-                                    unsigned int colopts)
+static void pretty_print_cmdnames(struct cmdnames *cmds, unsigned int colopts)
 {
        struct string_list list = STRING_LIST_INIT_NODUP;
        struct column_options copts;
@@ -146,7 +145,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,
        len = buf.len;
 
        while ((de = readdir(dir)) != NULL) {
-               int entlen;
+               size_t entlen;
 
                if (!starts_with(de->d_name, prefix))
                        continue;
@@ -157,8 +156,7 @@ static void list_commands_in_dir(struct cmdnames *cmds,
                        continue;
 
                entlen = strlen(de->d_name) - prefix_len;
-               if (has_extension(de->d_name, ".exe"))
-                       entlen -= 4;
+               strip_suffix(de->d_name, ".exe", &entlen);
 
                add_cmdname(cmds, de->d_name + prefix_len, entlen);
        }
@@ -209,14 +207,14 @@ void list_commands(unsigned int colopts,
                const char *exec_path = git_exec_path();
                printf_ln(_("available git commands in '%s'"), exec_path);
                putchar('\n');
-               pretty_print_string_list(main_cmds, colopts);
+               pretty_print_cmdnames(main_cmds, colopts);
                putchar('\n');
        }
 
        if (other_cmds->cnt) {
                printf_ln(_("git commands available from elsewhere on your $PATH"));
                putchar('\n');
-               pretty_print_string_list(other_cmds, colopts);
+               pretty_print_cmdnames(other_cmds, colopts);
                putchar('\n');
        }
 }