Skip to content

Commit 3caa823

Browse files
chriscoolgitster
authored andcommitted
help: fix configured help format taking over command line one
Since commit 7c3baa9 (help -a: do not unnecessarily look for a repository, 2009-09-04), the help format that is passed as a command line option is not used if an help format has been configured. This patch fixes that. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0afcb5f commit 3caa823

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

builtin-help.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ static struct man_viewer_info_list {
2323
} *man_viewer_info_list;
2424

2525
enum help_format {
26+
HELP_FORMAT_NONE,
2627
HELP_FORMAT_MAN,
2728
HELP_FORMAT_INFO,
2829
HELP_FORMAT_WEB,
2930
};
3031

3132
static int show_all = 0;
32-
static enum help_format help_format = HELP_FORMAT_MAN;
33+
static enum help_format help_format = HELP_FORMAT_NONE;
3334
static struct option builtin_help_options[] = {
3435
OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
3536
OPT_SET_INT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
@@ -415,10 +416,12 @@ int cmd_help(int argc, const char **argv, const char *prefix)
415416
{
416417
int nongit;
417418
const char *alias;
419+
enum help_format parsed_help_format;
418420
load_command_list("git-", &main_cmds, &other_cmds);
419421

420422
argc = parse_options(argc, argv, prefix, builtin_help_options,
421423
builtin_help_usage, 0);
424+
parsed_help_format = help_format;
422425

423426
if (show_all) {
424427
printf("usage: %s\n\n", git_usage_string);
@@ -437,13 +440,17 @@ int cmd_help(int argc, const char **argv, const char *prefix)
437440
setup_git_directory_gently(&nongit);
438441
git_config(git_help_config, NULL);
439442

443+
if (parsed_help_format != HELP_FORMAT_NONE)
444+
help_format = parsed_help_format;
445+
440446
alias = alias_lookup(argv[0]);
441447
if (alias && !is_git_command(argv[0])) {
442448
printf("`git %s' is aliased to `%s'\n", argv[0], alias);
443449
return 0;
444450
}
445451

446452
switch (help_format) {
453+
case HELP_FORMAT_NONE:
447454
case HELP_FORMAT_MAN:
448455
show_man_page(argv[0]);
449456
break;

0 commit comments

Comments
 (0)