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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jan 9, 2010 at 06:10 UTC
3caa82396ca8a78da05f7759570444e9a666b2e8
1 file changed
+8
-1
builtin-help.c
+8
-1
@@ -23,13 +23,14 @@ static struct man_viewer_info_list {
23
} *man_viewer_info_list;
24
25
enum help_format {
26
+ HELP_FORMAT_NONE,
27
HELP_FORMAT_MAN,
28
HELP_FORMAT_INFO,
29
HELP_FORMAT_WEB,
30
};
31
32
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;
34
static struct option builtin_help_options[] = {
35
OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
36
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)
416
{
417
int nongit;
418
const char *alias;
419
+ enum help_format parsed_help_format;
420
load_command_list("git-", &main_cmds, &other_cmds);
421
422
argc = parse_options(argc, argv, prefix, builtin_help_options,
423
builtin_help_usage, 0);
424
+ parsed_help_format = help_format;
425
426
if (show_all) {
427
printf("usage: %s\n\n", git_usage_string);
@@ -437,6 +440,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
440
setup_git_directory_gently(&nongit);
441
git_config(git_help_config, NULL);
442
443
+ if (parsed_help_format != HELP_FORMAT_NONE)
444
+ help_format = parsed_help_format;
445
+
446
alias = alias_lookup(argv[0]);
447
if (alias && !is_git_command(argv[0])) {
448
printf("`git %s' is aliased to `%s'\n", argv[0], alias);
@@ -444,6 +450,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
450
}
451
452
switch (help_format) {
453
+ case HELP_FORMAT_NONE:
454
case HELP_FORMAT_MAN:
455
show_man_page(argv[0]);
456
break;