X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=help.c;h=5d1a773ad7f3ed811c35a6b9fa8afe1697615cc8;hb=0989fe9623dc8d98033f6acdcc0c84ec28571b19;hp=d89d43796f3ee9d3689131d48861967048f5c5d7;hpb=2d3cfd77ad5305c132f7b23c192ae6c327443c95;p=git.git diff --git a/help.c b/help.c index d89d43796..5d1a773ad 100644 --- a/help.c +++ b/help.c @@ -527,20 +527,26 @@ static int is_git_command(const char *s) is_in_cmdlist(&other_cmds, s); } +static const char *prepend(const char *prefix, const char *cmd) +{ + size_t pre_len = strlen(prefix); + size_t cmd_len = strlen(cmd); + char *p = xmalloc(pre_len + cmd_len + 1); + memcpy(p, prefix, pre_len); + strcpy(p + pre_len, cmd); + return p; +} + static const char *cmd_to_page(const char *git_cmd) { if (!git_cmd) return "git"; else if (!prefixcmp(git_cmd, "git")) return git_cmd; - else { - int page_len = strlen(git_cmd) + 4; - char *p = xmalloc(page_len + 1); - strcpy(p, "git-"); - strcpy(p + 4, git_cmd); - p[page_len] = 0; - return p; - } + else if (is_git_command(git_cmd)) + return prepend("git-", git_cmd); + else + return prepend("git", git_cmd); } static void setup_man_path(void) @@ -649,12 +655,14 @@ int cmd_help(int argc, const char **argv, const char *prefix) if (show_all) { printf("usage: %s\n\n", git_usage_string); list_commands(); + printf("%s\n", git_more_info_string); return 0; } if (!argv[0]) { printf("usage: %s\n\n", git_usage_string); list_common_cmds_help(); + printf("\n%s\n", git_more_info_string); return 0; }