Code

mergetool: factor out common code
[git.git] / help.c
diff --git a/help.c b/help.c
index 341b9e370eec4fa90014249a63afac17b083b275..be8651a73977f860a87fb944f6fca52af41a2c28 100644 (file)
--- a/help.c
+++ b/help.c
@@ -58,7 +58,7 @@ static void add_cmdname(const char *name, int len)
                if (!cmdname)
                        oom();
        }
-       ent = malloc(sizeof(*ent) + len);
+       ent = xmalloc(sizeof(*ent) + len);
        if (!ent)
                oom();
        ent->len = len;
@@ -130,7 +130,7 @@ static void list_commands(const char *exec_path, const char *pattern)
                struct stat st;
                int entlen;
 
-               if (strncmp(de->d_name, "git-", 4))
+               if (prefixcmp(de->d_name, "git-"))
                        continue;
                strcpy(path+dirlen, de->d_name);
                if (stat(path, &st) || /* stat, not lstat */
@@ -168,8 +168,8 @@ static void list_common_cmds_help(void)
 
        puts("The most commonly used git commands are:");
        for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-               printf("    %s", common_cmds[i].name);
-               mput_char(' ', longest - strlen(common_cmds[i].name) + 4);
+               printf("   %s   ", common_cmds[i].name);
+               mput_char(' ', longest - strlen(common_cmds[i].name));
                puts(common_cmds[i].help);
        }
        puts("(use 'git help -a' to get a list of all installed git commands)");
@@ -179,7 +179,7 @@ static void show_man_page(const char *git_cmd)
 {
        const char *page;
 
-       if (!strncmp(git_cmd, "git", 3))
+       if (!prefixcmp(git_cmd, "git"))
                page = git_cmd;
        else {
                int page_len = strlen(git_cmd) + 4;