Skip to content

Commit

Permalink
help: drop prepend function in favor of xstrfmt
Browse files Browse the repository at this point in the history
This function predates xstrfmt, and its functionality is a
subset. Let's just use xstrfmt.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Sep 25, 2015
1 parent a5e03bf commit acd47ee
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,26 +295,16 @@ 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 (starts_with(git_cmd, "git"))
return git_cmd;
else if (is_git_command(git_cmd))
return prepend("git-", git_cmd);
return xstrfmt("git-%s", git_cmd);
else
return prepend("git", git_cmd);
return xstrfmt("git%s", git_cmd);
}

static void setup_man_path(void)
Expand Down

0 comments on commit acd47ee

Please sign in to comment.