summaryrefslogtreecommitdiff
path: root/builtin/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/help.c')
-rw-r--r--builtin/help.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/builtin/help.c b/builtin/help.c
index 4a5a079070..c257079ceb 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -1,8 +1,9 @@
-
/*
* Builtin help command
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "exec-cmd.h"
@@ -129,7 +130,6 @@ static void list_config_help(enum show_config_type type)
struct string_list keys = STRING_LIST_INIT_DUP;
struct string_list keys_uniq = STRING_LIST_INIT_DUP;
struct string_list_item *item;
- int i;
for (p = config_name_list; *p; p++) {
const char *var = *p;
@@ -156,7 +156,7 @@ static void list_config_help(enum show_config_type type)
e->prefix, e->placeholder);
string_list_sort(&keys);
- for (i = 0; i < keys.nr; i++) {
+ for (size_t i = 0; i < keys.nr; i++) {
const char *var = keys.items[i].string;
const char *wildcard, *tag, *cut;
const char *dot = NULL;
@@ -551,12 +551,12 @@ static void show_html_page(const char *page)
open_html(page_path.buf);
}
-static const char *check_git_cmd(const char* cmd)
+static char *check_git_cmd(const char *cmd)
{
char *alias;
if (is_git_command(cmd))
- return cmd;
+ return xstrdup(cmd);
alias = alias_lookup(cmd);
if (alias) {
@@ -589,14 +589,13 @@ static const char *check_git_cmd(const char* cmd)
die(_("bad alias.%s string: %s"), cmd,
split_cmdline_strerror(count));
free(argv);
- UNLEAK(alias);
return alias;
}
if (exclude_guides)
return help_unknown_cmd(cmd);
- return cmd;
+ return xstrdup(cmd);
}
static void no_help_format(const char *opt_mode, enum help_format fmt)
@@ -642,6 +641,7 @@ int cmd_help(int argc,
{
int nongit;
enum help_format parsed_help_format;
+ char *command = NULL;
const char *page;
argc = parse_options(argc, argv, prefix, builtin_help_options,
@@ -658,7 +658,7 @@ int cmd_help(int argc,
case HELP_ACTION_ALL:
opt_mode_usage(argc, "--all", help_format);
if (verbose) {
- setup_pager();
+ setup_pager(the_repository);
list_all_cmds_help(show_external_commands,
show_aliases);
return 0;
@@ -692,7 +692,7 @@ int cmd_help(int argc,
return 0;
case HELP_ACTION_CONFIG:
opt_mode_usage(argc, "--config", help_format);
- setup_pager();
+ setup_pager(the_repository);
list_config_help(SHOW_CONFIG_HUMAN);
printf("\n%s\n", _("'git help config' for more information"));
return 0;
@@ -713,9 +713,9 @@ int cmd_help(int argc,
if (help_format == HELP_FORMAT_NONE)
help_format = parse_help_format(DEFAULT_HELP_FORMAT);
- argv[0] = check_git_cmd(argv[0]);
+ command = check_git_cmd(argv[0]);
- page = cmd_to_page(argv[0]);
+ page = cmd_to_page(command);
switch (help_format) {
case HELP_FORMAT_NONE:
case HELP_FORMAT_MAN:
@@ -729,5 +729,6 @@ int cmd_help(int argc,
break;
}
+ free(command);
return 0;
}