{"thread":{"id":"22143","subject":"[PATCH] help: fix configured help format taking over command line one","startedAt":"2010-01-09T05:10:05Z","lastAt":"2010-01-09T05:10:05Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131165","messageId":"20100109051006.3569.45440.chriscool@tuxfamily.org","threadId":"22143","inReplyTo":null,"subject":"[PATCH] help: fix configured help format taking over command line one","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-01-09T05:10:05Z","receivedAt":"2010-01-09T05:10:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Since commit 7c3baa9 (help -a: do not unnecessarily look for a\nrepository, 2009-09-04), the help format that is passed as a\ncommand line option is not used if an help format has been\nconfigured. This patch fixes that.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin-help.c |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 09ad4b0..3182a2b 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -23,13 +23,14 @@ static struct man_viewer_info_list {\n } *man_viewer_info_list;\n \n enum help_format {\n+\tHELP_FORMAT_NONE,\n \tHELP_FORMAT_MAN,\n \tHELP_FORMAT_INFO,\n \tHELP_FORMAT_WEB,\n };\n \n static int show_all = 0;\n-static enum help_format help_format = HELP_FORMAT_MAN;\n+static enum help_format help_format = HELP_FORMAT_NONE;\n static struct option builtin_help_options[] = {\n \tOPT_BOOLEAN('a', \"all\", &show_all, \"print all available commands\"),\n \tOPT_SET_INT('m', \"man\", &help_format, \"show man page\", HELP_FORMAT_MAN),\n@@ -415,10 +416,12 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n \tconst char *alias;\n+\tenum help_format parsed_help_format;\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n \n \targc = parse_options(argc, argv, prefix, builtin_help_options,\n \t\t\tbuiltin_help_usage, 0);\n+\tparsed_help_format = help_format;\n \n \tif (show_all) {\n \t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n@@ -437,6 +440,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \tsetup_git_directory_gently(&nongit);\n \tgit_config(git_help_config, NULL);\n \n+\tif (parsed_help_format != HELP_FORMAT_NONE)\n+\t\thelp_format = parsed_help_format;\n+\n \talias = alias_lookup(argv[0]);\n \tif (alias && !is_git_command(argv[0])) {\n \t\tprintf(\"`git %s' is aliased to `%s'\\n\", argv[0], alias);\n@@ -444,6 +450,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t}\n \n \tswitch (help_format) {\n+\tcase HELP_FORMAT_NONE:\n \tcase HELP_FORMAT_MAN:\n \t\tshow_man_page(argv[0]);\n \t\tbreak;\n-- \n1.6.6.271.gc8799\n"}]}