{"thread":{"id":"29954","subject":"[PATCH 1/3] help: Fix help message for aliases","startedAt":"2012-03-15T02:52:47Z","lastAt":"2012-03-15T13:19:04Z","messageCount":16,"participants":["Namhyung Kim","Jeff King","김남형","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"187002","messageId":"1331779969-8641-1-git-send-email-namhyung.kim@lge.com","threadId":"29954","inReplyTo":null,"subject":"[PATCH 1/3] help: Fix help message for aliases","fromName":"Namhyung Kim","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T02:52:47Z","receivedAt":"2012-03-15T02:52:47Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"The current \"`git br' is aliased to `branch'\" looks a bit\nstrange. Prepend 'git' to aliased output too so that the\nend result will be looked like this:\n\n $ git help br\n `git br' is aliased to `git branch'\n\nSigned-off-by: Namhyung Kim <namhyung.kim@lge.com>\n---\n builtin/help.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 61ff798..f85c870 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\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+\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n \t\treturn 0;\n \t}\n \n-- \n1.7.9\n"},{"id":"187003","messageId":"1331779969-8641-2-git-send-email-namhyung.kim@lge.com","threadId":"29954","inReplyTo":"1331779969-8641-1-git-send-email-namhyung.kim@lge.com","subject":"[PATCH 2/3] help: Add '--follow-alias' option","fromName":"Namhyung Kim","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T02:52:48Z","receivedAt":"2012-03-15T02:52:48Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"The --follow-alias option will look up the alias definitions and\nuse the first word as a command. For example, if I set my aliases\nas follows:\n\n $ git help br\n `git br' is aliased to `git branch'\n $ git help ru\n `git ru' is aliased to `git remote update'\n\nadding --follow-alias (or -f) option will show man pages of\ngit-branch and git-remote, respectively.\n\nSigned-off-by: Namhyung Kim <namhyung.kim@lge.com>\n---\n Documentation/git-help.txt |    7 ++++++-\n builtin/help.c             |   25 ++++++++++++++++++++-----\n 2 files changed, 26 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-help.txt b/Documentation/git-help.txt\nindex 9e0b3f6..debf293 100644\n--- a/Documentation/git-help.txt\n+++ b/Documentation/git-help.txt\n@@ -8,7 +8,7 @@ git-help - display help information about git\n SYNOPSIS\n --------\n [verse]\n-'git help' [-a|--all|-i|--info|-m|--man|-w|--web] [COMMAND]\n+'git help' [-a|--all|-f|--follow-alias|-i|--info|-m|--man|-w|--web] [COMMAND]\n \n DESCRIPTION\n -----------\n@@ -34,6 +34,11 @@ OPTIONS\n \tPrints all the available commands on the standard output. This\n \toption supersedes any other option.\n \n+-f::\n+--follow-alias::\n+\tRead alias definitions and use its first word as a command name\n+\t(if any).\n+\n -i::\n --info::\n \tDisplay manual page for the command in the 'info' format. The\ndiff --git a/builtin/help.c b/builtin/help.c\nindex f85c870..00392ea 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -30,9 +30,12 @@ enum help_format {\n };\n \n static int show_all = 0;\n+static int follow_alias = 0;\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_BOOLEAN('f', \"follow-alias\", &follow_alias,\n+\t\t\t\"follow alias to resolve command name\"),\n \tOPT_SET_INT('m', \"man\", &help_format, \"show man page\", HELP_FORMAT_MAN),\n \tOPT_SET_INT('w', \"web\", &help_format, \"show manual in web browser\",\n \t\t\tHELP_FORMAT_WEB),\n@@ -415,6 +418,7 @@ static void show_html_page(const char *git_cmd)\n int cmd_help(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n+\tconst char *cmd;\n \tconst char *alias;\n \tenum help_format parsed_help_format;\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n@@ -443,22 +447,33 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \tif (parsed_help_format != HELP_FORMAT_NONE)\n \t\thelp_format = parsed_help_format;\n \n+\tcmd = argv[0];\n \talias = alias_lookup(argv[0]);\n \tif (alias && !is_git_command(argv[0])) {\n-\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n-\t\treturn 0;\n+\t\tchar *p;\n+\n+\t\tif (!follow_alias) {\n+\t\t\tprintf(\"`git %s' is aliased to `git %s'\\n\",\n+\t\t\t       argv[0], alias);\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tp = strchr(alias, ' ');\n+\t\tif (p)\n+\t\t\t*p = '\\0';\n+\t\tcmd = alias;\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\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.9\n"},{"id":"187004","messageId":"1331779969-8641-3-git-send-email-namhyung.kim@lge.com","threadId":"29954","inReplyTo":"1331779969-8641-1-git-send-email-namhyung.kim@lge.com","subject":"[PATCH 3/3] help: Add 'help.follow-alias' config item","fromName":"Namhyung Kim","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T02:52:49Z","receivedAt":"2012-03-15T02:52:49Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"The 'help.follow-alias' config option is used to determine the\ndefault value of '--follow-alias' option. To do this, move some\ncodes to honor the priority of command line options.\n\nSigned-off-by: Namhyung Kim <namhyung.kim@lge.com>\n---\n Documentation/git-help.txt |    8 ++++++++\n builtin/help.c             |   16 ++++++++--------\n 2 files changed, 16 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-help.txt b/Documentation/git-help.txt\nindex debf293..9725e9f 100644\n--- a/Documentation/git-help.txt\n+++ b/Documentation/git-help.txt\n@@ -80,6 +80,14 @@ line option:\n * \"info\" corresponds to '-i|--info',\n * \"web\" or \"html\" correspond to '-w|--web'.\n \n+help.follow-alias\n+~~~~~~~~~~~~~~~~~\n+\n+If --[no-]follow-alias command line option is not passed, the\n+'help.follow-alias' configuration variable will be checked. If it's\n+set to true, alias name will be resolved to its original command and\n+then will be displayed.\n+\n help.browser, web.browser and browser.<tool>.path\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/builtin/help.c b/builtin/help.c\nindex 00392ea..bf782ee 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -260,6 +260,10 @@ static int git_help_config(const char *var, const char *value, void *cb)\n \t\thelp_format = parse_help_format(value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"help.follow-alias\")) {\n+\t\tfollow_alias = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"man.viewer\")) {\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n@@ -420,12 +424,14 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \tint nongit;\n \tconst char *cmd;\n \tconst char *alias;\n-\tenum help_format parsed_help_format;\n+\n \tload_command_list(\"git-\", &main_cmds, &other_cmds);\n \n+\tsetup_git_directory_gently(&nongit);\n+\tgit_config(git_help_config, NULL);\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@@ -441,12 +447,6 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\treturn 0;\n \t}\n \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 \tcmd = argv[0];\n \talias = alias_lookup(argv[0]);\n \tif (alias && !is_git_command(argv[0])) {\n-- \n1.7.9\n"},{"id":"187008","messageId":"20120315041734.GD4149@sigill.intra.peff.net","threadId":"29954","inReplyTo":"1331779969-8641-1-git-send-email-namhyung.kim@lge.com","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-15T04:17:34Z","receivedAt":"2012-03-15T04:17:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 15, 2012 at 11:52:47AM +0900, Namhyung Kim wrote:\n\n> The current \"`git br' is aliased to `branch'\" looks a bit\n> strange. Prepend 'git' to aliased output too so that the\n> end result will be looked like this:\n> \n>  $ git help br\n>  `git br' is aliased to `git branch'\n\nI think that is a sensible improvement, but...\n\n> diff --git a/builtin/help.c b/builtin/help.c\n> index 61ff798..f85c870 100644\n> --- a/builtin/help.c\n> +++ b/builtin/help.c\n> @@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\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> +\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n>  \t\treturn 0;\n\nWhat output does this produce for:\n\n  $ git config alias.foo '!f() { git log $1@{u}..$1; }; f'\n  $ git help foo\n\n?\n\n-Peff\n"},{"id":"187009","messageId":"4F617AE2.9050700@lge.com","threadId":"29954","inReplyTo":"20120315041734.GD4149@sigill.intra.peff.net","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"김남형","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T05:15:14Z","receivedAt":"2012-03-15T05:15:14Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"Hi,\n\n2012-03-15 1:17 PM, Jeff King wrote:\n> On Thu, Mar 15, 2012 at 11:52:47AM +0900, Namhyung Kim wrote:\n>\n>> The current \"`git br' is aliased to `branch'\" looks a bit\n>> strange. Prepend 'git' to aliased output too so that the\n>> end result will be looked like this:\n>>\n>>   $ git help br\n>>   `git br' is aliased to `git branch'\n>\n> I think that is a sensible improvement, but...\n>\n>> diff --git a/builtin/help.c b/builtin/help.c\n>> index 61ff798..f85c870 100644\n>> --- a/builtin/help.c\n>> +++ b/builtin/help.c\n>> @@ -445,7 +445,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)\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>> +\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n>>   \t\treturn 0;\n>\n> What output does this produce for:\n>\n>    $ git config alias.foo '!f() { git log $1@{u}..$1; }; f'\n>    $ git help foo\n>\n> ?\n>\n\nOh, I didn't think of such a complicated case. Hmm, how about checking whether \nthe first word is a git command or not:\n\n\t\tprintf(\"`git %s' is aliased to `%s%s'\\n\", argv[0],\n\t\t\tis_git_command(first_word) ? \"git \" : \"\", alias);\n\nThanks,\nNamhyung\n"},{"id":"187010","messageId":"7vipi6mo93.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"1331779969-8641-1-git-send-email-namhyung.kim@lge.com","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T05:23:04Z","receivedAt":"2012-03-15T05:23:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung.kim@lge.com> writes:\n\n> -\t\tprintf(\"`git %s' is aliased to `%s'\\n\", argv[0], alias);\n> +\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n\nNAK.\n\nWhat would the above change will do to one of my favorite alias?\n\n$ git help who\n`git who' is aliased to `!sh -c 'git log -1 --format=\"%an <%ae>\" --author=\"$1\"' -'\n\nWouldn't removing \"git \" from the first phrase be a better solution?\n"},{"id":"187011","messageId":"4F6182C1.9080600@lge.com","threadId":"29954","inReplyTo":"7vipi6mo93.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"김남형","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T05:48:49Z","receivedAt":"2012-03-15T05:48:49Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"Hi,\n\n2012-03-15 2:23 PM, Junio C Hamano wrote:\n> Namhyung Kim <namhyung.kim@lge.com> writes:\n>\n>> -\t\tprintf(\"`git %s' is aliased to `%s'\\n\", argv[0], alias);\n>> +\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n>\n> NAK.\n>\n> What would the above change will do to one of my favorite alias?\n>\n> $ git help who\n> `git who' is aliased to `!sh -c 'git log -1 --format=\"%an<%ae>\" --author=\"$1\"' -'\n>\n> Wouldn't removing \"git \" from the first phrase be a better solution?\n>\n\nRight. But as I replied to Jeff King, it can be improved to check whether the \naliased output is such a complicated commands or not. Now I see that we can \nexamine if the first letter is '!'.\n\nThanks,\nNamhyung\n"},{"id":"187012","messageId":"7vehsummit.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"1331779969-8641-2-git-send-email-namhyung.kim@lge.com","subject":"Re: [PATCH 2/3] help: Add '--follow-alias' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T06:00:26Z","receivedAt":"2012-03-15T06:00:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung.kim@lge.com> writes:\n\n> The --follow-alias option will look up the alias definitions and\n> use the first word as a command. For example, if I set my aliases\n> as follows:\n>\n>  $ git help br\n>  `git br' is aliased to `git branch'\n>  $ git help ru\n>  `git ru' is aliased to `git remote update'\n>\n> adding --follow-alias (or -f) option will show man pages of\n> git-branch and git-remote, respectively.\n\nWhat would happen when somebody has this?\n\n\t[alias]\n        \tbr = branch --list\n\n\t$ git help --follow-alias br\n\t... man page for git-branch is shown ...\n\nNAK.\n\n> +-f::\n> +--follow-alias::\n> +\tRead alias definitions and use its first word as a command name\n> +\t(if any).\n\nAlso, please do not let a potentially ill-conceived option to squat on a\nshort and sweet single letter option name, until it proves to be useful.\n"},{"id":"187013","messageId":"7v7gymmm9a.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"1331779969-8641-3-git-send-email-namhyung.kim@lge.com","subject":"Re: [PATCH 3/3] help: Add 'help.follow-alias' config item","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T06:06:09Z","receivedAt":"2012-03-15T06:06:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung.kim@lge.com> writes:\n\n> The 'help.follow-alias' config option is used to determine the\n> default value of '--follow-alias' option. To do this, move some\n> codes to honor the priority of command line options.\n\nHow badly would this change break what 7c3baa9 (help -a: do not\nunnecessarily look for a repository, 2009-09-04) tried to fix?\n\n> diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt\n> index debf293..9725e9f 100644\n> --- a/Documentation/git-help.txt\n> +++ b/Documentation/git-help.txt\n> @@ -80,6 +80,14 @@ line option:\n>  * \"info\" corresponds to '-i|--info',\n>  * \"web\" or \"html\" correspond to '-w|--web'.\n>  \n> +help.follow-alias\n\nPlease be consistent with existing ones.  I think we spell multi-word\nvariable names without hyphens.\n"},{"id":"187014","messageId":"4F6188FB.7020406@lge.com","threadId":"29954","inReplyTo":"7vehsummit.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/3] help: Add '--follow-alias' option","fromName":"김남형","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T06:15:23Z","receivedAt":"2012-03-15T06:15:23Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"2012-03-15 3:00 PM, Junio C Hamano wrote:\n> Namhyung Kim<namhyung.kim@lge.com>  writes:\n>\n>> The --follow-alias option will look up the alias definitions and\n>> use the first word as a command. For example, if I set my aliases\n>> as follows:\n>>\n>>   $ git help br\n>>   `git br' is aliased to `git branch'\n>>   $ git help ru\n>>   `git ru' is aliased to `git remote update'\n>>\n>> adding --follow-alias (or -f) option will show man pages of\n>> git-branch and git-remote, respectively.\n>\n> What would happen when somebody has this?\n>\n> \t[alias]\n>          \tbr = branch --list\n>\n> \t$ git help --follow-alias br\n> \t... man page for git-branch is shown ...\n>\n> NAK.\n>\n\nI'm sorry I don't understand what you meant by this. What should be happened \nfor this?\n\n\n>> +-f::\n>> +--follow-alias::\n>> +\tRead alias definitions and use its first word as a command name\n>> +\t(if any).\n>\n> Also, please do not let a potentially ill-conceived option to squat on a\n> short and sweet single letter option name, until it proves to be useful.\n>\n\nOK, will be careful next time.\n\nThanks,\nNamhyung\n"},{"id":"187015","messageId":"7v399amlox.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"4F6182C1.9080600@lge.com","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T06:18:22Z","receivedAt":"2012-03-15T06:18:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"김남형 <namhyung.kim@lge.com> writes:\n\n> 2012-03-15 2:23 PM, Junio C Hamano wrote:\n>> Namhyung Kim <namhyung.kim@lge.com> writes:\n>>\n>>> -\t\tprintf(\"`git %s' is aliased to `%s'\\n\", argv[0], alias);\n>>> +\t\tprintf(\"`git %s' is aliased to `git %s'\\n\", argv[0], alias);\n>>\n>> NAK.\n>>\n>> What would the above change will do to one of my favorite alias?\n>>\n>> $ git help who\n>> `git who' is aliased to `!sh -c 'git log -1 --format=\"%an<%ae>\" --author=\"$1\"' -'\n>>\n>> Wouldn't removing \"git \" from the first phrase be a better solution?\n>\n> Right. But as I replied to Jeff King, it can be improved to check\n> whether the aliased output is such a complicated commands or not. Now\n> I see that we can examine if the first letter is '!'.\n\nTrimming the four bytes from the beginning would be an improvement by\nitself---it makes the output shorter without losing information.\n\nAnd for your \"[alias] br = branch\", you will see:\n\n\t`br` is aliased to `branch`\n\nwhich after all is exactly what the user wrote in the configuration.\n\nThere is even a worse problem with your \"I can look at '!' at the\nbeginning\".  By tweaking the part that is the answer to what the user\nasked, depending on the value the user configured, you would not be able\nto tell from this output:\n\n\t`git br` is aliased to `git branch`\n\nwhich one the user really has between these two, no?\n\n\t[alias] br = branch\n        [alias] br = !git branch\n\nIn short, I do not think there is any merit trying to be clever and cute\nwhen answering \"git help <alias>\".  The cleverness will actively hurt by\nobscuring the details of the answer you are giving in response to user's\nquestion.\n\nExactly the same \"don't obscure by trying to be clever and cute\" comment\napplies to the --follow-alias patch. There is nothing wrong in the series\nof revelation:\n\n 1. The user types 'git help br',\n 2. The user then realizes it is aliased to 'branch' (this could even\n    be 'branch --list'), then\n 3. The user asks 'git help branch' (and perhaps goes to read on --list)\n"},{"id":"187016","messageId":"7vvcm6l6w0.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"4F6188FB.7020406@lge.com","subject":"Re: [PATCH 2/3] help: Add '--follow-alias' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T06:23:27Z","receivedAt":"2012-03-15T06:23:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"김남형 <namhyung.kim@lge.com> writes:\n\n> 2012-03-15 3:00 PM, Junio C Hamano wrote:\n>> Namhyung Kim<namhyung.kim@lge.com>  writes:\n>>\n>>> The --follow-alias option will look up the alias definitions and\n>>> use the first word as a command. For example, if I set my aliases\n>>> as follows:\n>>>\n>>>   $ git help br\n>>>   `git br' is aliased to `git branch'\n>>>   $ git help ru\n>>>   `git ru' is aliased to `git remote update'\n>>>\n>>> adding --follow-alias (or -f) option will show man pages of\n>>> git-branch and git-remote, respectively.\n>>\n>> What would happen when somebody has this?\n>>\n>> \t[alias]\n>>          \tbr = branch --list\n>>\n>> \t$ git help --follow-alias br\n>> \t... man page for git-branch is shown ...\n>>\n>> NAK.\n>\n> I'm sorry I don't understand what you meant by this. What should be\n> happened for this?\n\nYou _somehow_ restict the output, or at least draw the user's attention,\nto the description of --list mode in the resulting \"git-branch\" manual.\n\nI do not think that is feasible.\n\nBut showing the whole manual page, without telling the user that \"br\" is\nnot aliased to a plain vanilla \"branch\" without any option, is not a\nsolution, especially if you are going to let the user set a configuration\nvariable to allow him to forget about this setting. Progressive revelation\nwould not have such a downside and I think it is more appropriate approach\nfor something like \"help\".\n"},{"id":"187017","messageId":"4F618C30.2030407@lge.com","threadId":"29954","inReplyTo":"7v7gymmm9a.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] help: Add 'help.follow-alias' config item","fromName":"Namhyung Kim","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T06:29:04Z","receivedAt":"2012-03-15T06:29:04Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"2012-03-15 3:06 PM, Junio C Hamano wrote:\n> Namhyung Kim<namhyung.kim@lge.com>  writes:\n>\n>> The 'help.follow-alias' config option is used to determine the\n>> default value of '--follow-alias' option. To do this, move some\n>> codes to honor the priority of command line options.\n>\n> How badly would this change break what 7c3baa9 (help -a: do not\n> unnecessarily look for a repository, 2009-09-04) tried to fix?\n>\n\nOops, I was completely unaware of the problem, sorry :(.\n\n\n>> diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt\n>> index debf293..9725e9f 100644\n>> --- a/Documentation/git-help.txt\n>> +++ b/Documentation/git-help.txt\n>> @@ -80,6 +80,14 @@ line option:\n>>   * \"info\" corresponds to '-i|--info',\n>>   * \"web\" or \"html\" correspond to '-w|--web'.\n>>\n>> +help.follow-alias\n>\n> Please be consistent with existing ones.  I think we spell multi-word\n> variable names without hyphens.\n>\n\nWill fix if you're OK with this series.\n\nThanks,\nNamhyung\n"},{"id":"187018","messageId":"4F619046.1050308@lge.com","threadId":"29954","inReplyTo":"7vvcm6l6w0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/3] help: Add '--follow-alias' option","fromName":"Namhyung Kim","fromEmail":"namhyung.kim@lge.com","sentAt":"2012-03-15T06:46:30Z","receivedAt":"2012-03-15T06:46:30Z","isPatch":true,"sender":{"key":"namhyung@gmail.com","avatar":"https://avatars.githubusercontent.com/u/48503?v=4"},"body":"2012-03-15 3:23 PM, Junio C Hamano wrote:\n> 김남형 <namhyung.kim@lge.com> writes:\n>> 2012-03-15 3:00 PM, Junio C Hamano wrote:\n>>> Namhyung Kim <namhyung.kim@lge.com> writes:\n>>>\n>>>> The --follow-alias option will look up the alias definitions and\n>>>> use the first word as a command. For example, if I set my aliases\n>>>> as follows:\n>>>>\n>>>>    $ git help br\n>>>>    `git br' is aliased to `git branch'\n>>>>    $ git help ru\n>>>>    `git ru' is aliased to `git remote update'\n>>>>\n>>>> adding --follow-alias (or -f) option will show man pages of\n>>>> git-branch and git-remote, respectively.\n>>>\n>>> What would happen when somebody has this?\n>>>\n>>> \t[alias]\n>>>           \tbr = branch --list\n>>>\n>>> \t$ git help --follow-alias br\n>>> \t... man page for git-branch is shown ...\n>>>\n>>> NAK.\n>>\n>> I'm sorry I don't understand what you meant by this. What should be\n>> happened for this?\n>\n> You _somehow_ restict the output, or at least draw the user's attention,\n> to the description of --list mode in the resulting \"git-branch\" manual.\n>\n> I do not think that is feasible.\n>\n\nActually I was thinking about moving to an appropriate point in the document \nby checking second argument (if any) and searching it (using regexp?). But I \ncoundn't be sure it'd be possible too.\n\n\n> But showing the whole manual page, without telling the user that \"br\" is\n> not aliased to a plain vanilla \"branch\" without any option, is not a\n> solution, especially if you are going to let the user set a configuration\n> variable to allow him to forget about this setting. Progressive revelation\n> would not have such a downside and I think it is more appropriate approach\n> for something like \"help\".\n>\n\nOK. That makes sense to me too. This was just a quick thought hoping that can \nbe helpful for someone who uses alias as a simple abbreviation.\n\nThanks for taking your time and giving me detailed comments.\nNamhyung\n"},{"id":"187021","messageId":"7vbonyl4rv.fsf@alter.siamese.dyndns.org","threadId":"29954","inReplyTo":"4F619046.1050308@lge.com","subject":"Re: [PATCH 2/3] help: Add '--follow-alias' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-15T07:09:08Z","receivedAt":"2012-03-15T07:09:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Namhyung Kim <namhyung.kim@lge.com> writes:\n\n>> You _somehow_ restict the output, or at least draw the user's attention,\n>> to the description of --list mode in the resulting \"git-branch\" manual.\n>>\n>> I do not think that is feasible.\n>\n> Actually I was thinking about moving to an appropriate point in the\n> document by checking second argument (if any) and searching it (using\n> regexp?). But I coundn't be sure it'd be possible too.\n\nI don't think it is feasible.\nThink \"[alias] lgf = log --oneline --first-parent\".\n\n>> But showing the whole manual page, without telling the user that \"br\" is\n>> not aliased to a plain vanilla \"branch\" without any option, is not a\n>> solution, especially if you are going to let the user set a configuration\n>> variable to allow him to forget about this setting. Progressive revelation\n>> would not have such a downside and I think it is more appropriate approach\n>> for something like \"help\".\n>\n> OK. That makes sense to me too. This was just a quick thought hoping\n> that can be helpful for someone who uses alias as a simple\n> abbreviation.\n\nYeah, I would have been the first to cheer-lead an effort to make things\nclever, cute and even dwim if this were about a real command that is an\nintegral part of people's everyday life. Once people understand what it is\ndoing, they will even appreciate the cleverness.\n\nBut help is the entry point for the understanding. It is safer to keep it\nsimple and predictable.\n"},{"id":"187044","messageId":"20120315131903.GA8467@sigill.intra.peff.net","threadId":"29954","inReplyTo":"4F617AE2.9050700@lge.com","subject":"Re: [PATCH 1/3] help: Fix help message for aliases","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-03-15T13:19:04Z","receivedAt":"2012-03-15T13:19:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 15, 2012 at 02:15:14PM +0900, 김남형 wrote:\n\n> >What output does this produce for:\n> >\n> >   $ git config alias.foo '!f() { git log $1@{u}..$1; }; f'\n> >   $ git help foo\n> >\n> >?\n> >\n> \n> Oh, I didn't think of such a complicated case. Hmm, how about\n> checking whether the first word is a git command or not:\n> \n> \t\tprintf(\"`git %s' is aliased to `%s%s'\\n\", argv[0],\n> \t\t\tis_git_command(first_word) ? \"git \" : \"\", alias);\n\nI think the right solution is to just look for \"!\", which is what tells\ngit it is a shell command.\n\n-Peff\n"}]}