Make fetch a builtin
[gitweb.git] / help.c
diff --git a/help.c b/help.c
index b6674635a2e08197cc13aaa6acbe6290a303d6b3..1cd33ece6bcec6f71c6749205c18c0f413034d89 100644 (file)
--- a/help.c
+++ b/help.c
@@ -31,12 +31,6 @@ static int term_columns(void)
        return 80;
 }
 
-static void oom(void)
-{
-       fprintf(stderr, "git: out of memory\n");
-       exit(1);
-}
-
 static inline void mput_char(char c, unsigned int num)
 {
        while(num--)
@@ -54,13 +48,9 @@ static void add_cmdname(const char *name, int len)
        struct cmdname *ent;
        if (cmdname_alloc <= cmdname_cnt) {
                cmdname_alloc = cmdname_alloc + 200;
-               cmdname = realloc(cmdname, cmdname_alloc * sizeof(*cmdname));
-               if (!cmdname)
-                       oom();
+               cmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));
        }
-       ent = malloc(sizeof(*ent) + len);
-       if (!ent)
-               oom();
+       ent = xmalloc(sizeof(*ent) + len);
        ent->len = len;
        memcpy(ent->name, name, len);
        ent->name[len] = 0;
@@ -130,7 +120,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 */
@@ -179,7 +169,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;
@@ -229,5 +219,3 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
        return 0;
 }
-
-