X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=help.c;h=6a9af4d175f2fe9724a2844df63e4011ba91f1b3;hb=7da3bf372cfcd25ea44164afb90c306836b62e23;hp=0824c25226ad7b106e56d1b7c23fad40eed92749;hpb=0f2ca9d5c99436d048bfe0a7161b4365a731938f;p=git.git diff --git a/help.c b/help.c index 0824c2522..6a9af4d17 100644 --- a/help.c +++ b/help.c @@ -3,12 +3,11 @@ * * Builtin help-related commands (help, usage, version) */ -#include #include "cache.h" #include "builtin.h" #include "exec_cmd.h" #include "common-cmds.h" - +#include /* most GUI terminals set COLUMNS (although some don't export it) */ static int term_columns(void) @@ -32,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--) @@ -55,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; @@ -131,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 */ @@ -169,8 +158,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)"); @@ -180,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;