{"thread":{"id":"15261","subject":"[PATCH] Allow 'git cmd -h' outside of repository","startedAt":"2008-08-28T21:28:37Z","lastAt":"2008-08-29T11:52:55Z","messageCount":4,"participants":["SZEDER Gábor","Johannes Schindelin","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"89013","messageId":"1219958917-22780-1-git-send-email-szeder@ira.uka.de","threadId":"15261","inReplyTo":null,"subject":"[PATCH] Allow 'git cmd -h' outside of repository","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-08-28T21:28:37Z","receivedAt":"2008-08-28T21:28:37Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Printing usage strings of git commands should obviously not depend on\nthe command being run inside a git repository.  However, in case of a\ncommand requiring a repository, the command line options are parsed only\nafter it is ensured that the command was started inside a repository,\nresulting in a 'fatal: Not a git repository' if 'git cmd -h' wasn't\nexecuted inside a repository.\n\nTo get around this issue, we will check early for the presence of '-h'\noption, and skip ensuring that the command is run inside a repository.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n git.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 37b1d76..af53472 100644\n--- a/git.c\n+++ b/git.c\n@@ -380,6 +380,10 @@ static void handle_internal_command(int argc, const char **argv)\n \t\tstruct cmd_struct *p = commands+i;\n \t\tif (strcmp(p->cmd, cmd))\n \t\t\tcontinue;\n+\t\t/* Don't require repository if only usage string is requested */\n+\t\tif (argc > 1 && !strcmp(argv[1], \"-h\")) {\n+\t\t\tp->option = 0;\n+\t\t}\n \t\texit(run_command(p, argc, argv));\n \t}\n }\n-- \n1.6.0.1.133.g10dd.dirty\n"},{"id":"89122","messageId":"alpine.DEB.1.00.0808291333010.24820@pacific.mpi-cbg.de.mpi-cbg.de","threadId":"15261","inReplyTo":"1219958917-22780-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH] Allow 'git cmd -h' outside of repository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-08-29T11:35:02Z","receivedAt":"2008-08-29T11:35:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 28 Aug 2008, SZEDER Gábor wrote:\n\n> Printing usage strings of git commands should obviously not depend on \n> the command being run inside a git repository.  However, in case of a \n> command requiring a repository, the command line options are parsed only \n> after it is ensured that the command was started inside a repository, \n> resulting in a 'fatal: Not a git repository' if 'git cmd -h' wasn't \n> executed inside a repository.\n> \n> To get around this issue, we will check early for the presence of '-h'\n> option, and skip ensuring that the command is run inside a repository.\n\nYou miss the fact that \"git grep -h\" does not mean \"show usage\".  Oh, and \n\"git ls-remote -h\" neither.  Three times's a charm: \"git show-ref -h\" does \nnot show the help either.\n\nI am also not quite certain if we should not just tout \"git help <cmd>\" as \nthe official way to request help.\n\nCiao,\nDscho"},{"id":"89123","messageId":"fcaeb9bf0808290444n579590a3ob01f7b4178e7a210@mail.gmail.com","threadId":"15261","inReplyTo":"alpine.DEB.1.00.0808291333010.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH] Allow 'git cmd -h' outside of repository","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-08-29T11:44:55Z","receivedAt":"2008-08-29T11:44:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 8/29/08, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n>\n>  On Thu, 28 Aug 2008, SZEDER Gábor wrote:\n>\n>  > Printing usage strings of git commands should obviously not depend on\n>  > the command being run inside a git repository.  However, in case of a\n>  > command requiring a repository, the command line options are parsed only\n>  > after it is ensured that the command was started inside a repository,\n>  > resulting in a 'fatal: Not a git repository' if 'git cmd -h' wasn't\n>  > executed inside a repository.\n>  >\n>  > To get around this issue, we will check early for the presence of '-h'\n>  > option, and skip ensuring that the command is run inside a repository.\n>\n>\n> You miss the fact that \"git grep -h\" does not mean \"show usage\".  Oh, and\n>  \"git ls-remote -h\" neither.  Three times's a charm: \"git show-ref -h\" does\n>  not show the help either.\n>\n>  I am also not quite certain if we should not just tout \"git help <cmd>\" as\n>  the official way to request help.\n\nNo we should not (at least to me), usage strings are shorter and don't\nrequire man.  As for allowing \"git cmd -h\" outside repository, I think\nJeff's idea of refactoring setup procedure, setting up if possible but\nnot barfing, would solve it.\n-- \nDuy\n"},{"id":"89124","messageId":"20080829115255.GD8000@neumann","threadId":"15261","inReplyTo":"alpine.DEB.1.00.0808291333010.24820@pacific.mpi-cbg.de.mpi-cbg.de","subject":"Re: [PATCH] Allow 'git cmd -h' outside of repository","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-08-29T11:52:55Z","receivedAt":"2008-08-29T11:52:55Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"On Fri, Aug 29, 2008 at 01:35:02PM +0200, Johannes Schindelin wrote:\n> You miss the fact that \"git grep -h\" does not mean \"show usage\".  Oh, and \n> \"git ls-remote -h\" neither.  Three times's a charm: \"git show-ref -h\" does \n> not show the help either.\nyou are right with grep and show-ref.  However, ls-remote does not\nrequire a repository, so it would not be affected by this patch.\n\n> I am also not quite certain if we should not just tout \"git help <cmd>\" as \n> the official way to request help.\nWell, I would prefer to keep the short usage.\n\nBut anyway, having this inconsistency with the -h option across git\ncommands is bad.\n\nRegards,\nGábor\n"}]}