{"thread":{"id":"22702","subject":"[PATCH] show help message also for aliased commands","startedAt":"2010-02-18T01:29:22Z","lastAt":"2010-02-18T02:18:50Z","messageCount":3,"participants":["Patrick Sudowe","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"134911","messageId":"1266456562-88841-1-git-send-email-patrick.sudowe@rwth-aachen.de","threadId":"22702","inReplyTo":null,"subject":"[PATCH] show help message also for aliased commands","fromName":"Patrick Sudowe","fromEmail":"patrick.sudowe@rwth-aachen.de","sentAt":"2010-02-18T01:29:22Z","receivedAt":"2010-02-18T01:29:22Z","isPatch":true,"sender":{"key":"patrick.sudowe@rwth-aachen.de","avatar":null},"body":"git help 'alias' currently only shows the actual git command\n'alias' refers to. This patch changes the behavior so that\nthe help for the actual git command is shown. The user usually\nknows the aliases defined, and sometimes its just more convenient\nto type something like git help co than git help checkout\nto find out about some rarely used option.\nThe original message is still there, so users do not face\nunexpected or surprising behavior.\n---\n builtin-help.c |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-help.c b/builtin-help.c\nindex 3182a2b..4d8906d 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -416,6 +416,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n \tconst char *alias;\n+\tconst char *cmd;\n \tenum help_format parsed_help_format;\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n \n@@ -446,19 +447,22 @@ int cmd_help(int argc, const char **argv, const char *prefix)\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-\t\treturn 0;\n+\t\tcmd = alias;\n+\t} else {\n+\t\tcmd = argv[0];\n \t}\n \n+\n \tswitch (help_format) {\n \tcase HELP_FORMAT_NONE:\n \tcase HELP_FORMAT_MAN:\n-\t\tshow_man_page(argv[0]);\n+\t\tshow_man_page(cmd);\n \t\tbreak;\n \tcase HELP_FORMAT_INFO:\n-\t\tshow_info_page(argv[0]);\n+\t\tshow_info_page(cmd);\n \t\tbreak;\n \tcase HELP_FORMAT_WEB:\n-\t\tshow_html_page(argv[0]);\n+\t\tshow_html_page(cmd);\n \t\tbreak;\n \t}\n \n-- \n1.7.0\n"},{"id":"134917","messageId":"7v635vwatn.fsf@alter.siamese.dyndns.org","threadId":"22702","inReplyTo":"1266456562-88841-1-git-send-email-patrick.sudowe@rwth-aachen.de","subject":"Re: [PATCH] show help message also for aliased commands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-18T02:13:08Z","receivedAt":"2010-02-18T02:13:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Sudowe <patrick.sudowe@rwth-aachen.de> writes:\n\n> git help 'alias' currently only shows the actual git command\n> 'alias' refers to. This patch changes the behavior so that\n> the help for the actual git command is shown.\n\nI somehow think this is a horrible change.\n\nI have \"[alias] lg = log --oneline --no-merges\" and I do appreciate that\nit tells the expansion, because I also have other similar ones like\n\"[alias] lgm = log --notes-ref=amlog\", \"lgf\", etc.\n\nI don't want the expansion to be erased by manual page of \"log\";\ntypically the output from man is piped to less(1).\n\nBesides, I may not know what \"log\" does, but at least I studied what\noptions it takes when coming up with the hardcoded leading options\nalready.  I don't want to see the manual page of \"log\" by default when I\nask git about \"lg\".  If git tells me \"lg\" expands to \"log --oneline\", and\nI do not remember what other options \"log\" takes, I'll ask git myself\nabout \"log\", not \"lg\".\n"},{"id":"134919","messageId":"20100218021850.GB21693@coredump.intra.peff.net","threadId":"22702","inReplyTo":"1266456562-88841-1-git-send-email-patrick.sudowe@rwth-aachen.de","subject":"Re: [PATCH] show help message also for aliased commands","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-02-18T02:18:50Z","receivedAt":"2010-02-18T02:18:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 18, 2010 at 02:29:22AM +0100, Patrick Sudowe wrote:\n\n> git help 'alias' currently only shows the actual git command\n> 'alias' refers to. This patch changes the behavior so that\n> the help for the actual git command is shown. The user usually\n> knows the aliases defined, and sometimes its just more convenient\n> to type something like git help co than git help checkout\n> to find out about some rarely used option.\n> The original message is still there, so users do not face\n> unexpected or surprising behavior.\n\nWon't the original message get eaten when 'man' starts a pager (I know\nthere are other, non-paged ways of showing the help, but man is the\ndefault).\n\n> @@ -446,19 +447,22 @@ int cmd_help(int argc, const char **argv, const char *prefix)\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> -\t\treturn 0;\n> +\t\tcmd = alias;\n> +\t} else {\n> +\t\tcmd = argv[0];\n>  \t}\n>  \n> +\n>  \tswitch (help_format) {\n>  \tcase HELP_FORMAT_NONE:\n>  \tcase HELP_FORMAT_MAN:\n> -\t\tshow_man_page(argv[0]);\n> +\t\tshow_man_page(cmd);\n\nThis breaks horribly for all but the simplest of aliases. This works:\n\n  $ git config alias.co checkout\n  $ git help co\n\nBut this would need to trim it down to just \"log\":\n\n  $ git config alias.lp 'log -p'\n  $ git help lp\n  `git lp' is aliased to `log -p'\n  No manual entry for gitlog -p\n\nAnd this is just impossible:\n\n  $ git config alias.jive '!sh -c \"git log | jive\"'\n  $ git help jive\n  `git jive' is aliased to `!sh -c \"git log | jive\"'\n  No manual entry for git!sh -c \"git log | jive\"\n\n-Peff\n"}]}