{"thread":{"id":"14745","subject":"What is 'git BRANCH'?","startedAt":"2008-07-29T22:18:29Z","lastAt":"2008-07-30T05:14:53Z","messageCount":8,"participants":["Jurko Gospodnetić","Junio C Hamano","Kevin Ballard","Sverre Rabbelier","Eric Raible","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"85525","messageId":"g6o4vi$rap$1@ger.gmane.org","threadId":"14745","inReplyTo":null,"subject":"What is 'git BRANCH'?","fromName":"Jurko Gospodnetić","fromEmail":"jurko.gospodnetic@docte.hr","sentAt":"2008-07-29T22:18:29Z","receivedAt":"2008-07-29T22:18:29Z","isPatch":false,"sender":{"key":"jurko.gospodnetic@docte.hr","avatar":null},"body":"   Hi.\n\n   I typed in \"git BRANCH\" by accident and got the error message: \n\"fatal: cannot handle BRANCH internally\".\n\n   What does that mean?\n\n   It is different from the usual \"git: 'yada-yada' is not a \ngit-command. See 'git --help'.\" message you get when you type in an \nincorrect command name.\n\n   Just curious...\n\n   Best regards,\n     Jurko Gospodnetić\n"},{"id":"85526","messageId":"7vej5cba6z.fsf@gitster.siamese.dyndns.org","threadId":"14745","inReplyTo":"g6o4vi$rap$1@ger.gmane.org","subject":"Re: What is 'git BRANCH'?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-29T22:24:36Z","receivedAt":"2008-07-29T22:24:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jurko Gospodnetić <jurko.gospodnetic@docte.hr> writes:\n\n>   Hi.\n>\n>   I typed in \"git BRANCH\" by accident and got the error message:\n> \"fatal: cannot handle BRANCH internally\".\n>\n>   What does that mean?\n>\n>   It is different from the usual \"git: 'yada-yada' is not a\n> git-command. See 'git --help'.\" message you get when you type in an\n> incorrect command name.\n\nJust a guess; your git is installed on a case-challenged filesystem?\n"},{"id":"85528","messageId":"DEBF93FC-BA8D-4513-B4EE-A8648DA1D591@sb.org","threadId":"14745","inReplyTo":"7vej5cba6z.fsf@gitster.siamese.dyndns.org","subject":"Re: What is 'git BRANCH'?","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-07-29T22:32:51Z","receivedAt":"2008-07-29T22:32:51Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Jul 29, 2008, at 3:24 PM, Junio C Hamano wrote:\n\n> Jurko Gospodnetić <jurko.gospodnetic@docte.hr> writes:\n>\n>>  Hi.\n>>\n>>  I typed in \"git BRANCH\" by accident and got the error message:\n>> \"fatal: cannot handle BRANCH internally\".\n>>\n>>  What does that mean?\n>>\n>>  It is different from the usual \"git: 'yada-yada' is not a\n>> git-command. See 'git --help'.\" message you get when you type in an\n>> incorrect command name.\n>\n> Just a guess; your git is installed on a case-challenged filesystem?\n\n From what I can tell, this happens when you execute one of the git-*  \nbuiltin binaries using a name that doesn't actually match the binary,  \ncase-sensitively. When you type `git BRANCH` on OS X, git matches that  \nagainst the git-branch binary and executes it, but argv[0] contains  \n\"git-BRANCH\". When this is compared by the git-branch binary to the  \nlist of internal commands, it comes up empty, and the fallback code  \n(to die with \"fatal: cannot handle BRANCH internally\") gets executed  \ninstead.\n\nIn other words, this is identical to running `/usr/local/libexec/git- \ncore/git-BRANCH` or to doing something like `exec -a git-BRANCH /usr/ \nlocal/libexec/git-core/git-branch` (this example should work on any  \nfilesystem).\n\n-Kevin Ballard\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n"},{"id":"85530","messageId":"7v63qob9hz.fsf@gitster.siamese.dyndns.org","threadId":"14745","inReplyTo":"7vej5cba6z.fsf@gitster.siamese.dyndns.org","subject":"Re: What is 'git BRANCH'?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-29T22:39:36Z","receivedAt":"2008-07-29T22:39:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jurko Gospodnetić <jurko.gospodnetic@docte.hr> writes:\n>\n>>   Hi.\n>>\n>>   I typed in \"git BRANCH\" by accident and got the error message:\n>> \"fatal: cannot handle BRANCH internally\".\n>>\n>>   What does that mean?\n>>\n>>   It is different from the usual \"git: 'yada-yada' is not a\n>> git-command. See 'git --help'.\" message you get when you type in an\n>> incorrect command name.\n>\n> Just a guess; your git is installed on a case-challenged filesystem?\n\nYeah, that must be it.  This can happen on MacOS and Windows, I would\nimagine.\n\n-- >8 --\n[PATCH] Fail on unknown command sensibly on case-challenged filesystems\n\nThe callchain on a case-challenged filesystem when the user runs \"git\nBRANCH\" looks like this:\n\n  - main(): git BRANCH\n   - execv_dashed_external(\"BRANCH\")\n    - execvp(\"git-BRANCH\")\n\n     - main(): git-BRANCH\n      - prefixcmp(\"git-BRANCH\", \"git-\")\n       - handle_internal_command()\n         struct cmd_struct commands[] does not have \"BRANCH\"\n         so it returns, instead of exiting.\n\nWhen the \"git wrapper\" execs \"git-BRANCH\", if your filesystem knows\n\"branch\" and \"BRANCH\" are different, execvp() would fail and we will see\nthe familiar error message from the git.c::main().\n\nHowever, if execvp() succeeds, we feed an unknown command name to\nhandle_internal_command() and it triggers a different error message.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 37b1d76..c99e769 100644\n--- a/git.c\n+++ b/git.c\n@@ -448,7 +448,7 @@ int main(int argc, const char **argv)\n \t\tcmd += 4;\n \t\targv[0] = cmd;\n \t\thandle_internal_command(argc, argv);\n-\t\tdie(\"cannot handle %s internally\", cmd);\n+\t\thelp_unknown_cmd(cmd);\n \t}\n \n \t/* Look for flags.. */\n"},{"id":"85531","messageId":"488F9D17.8020703@docte.hr","threadId":"14745","inReplyTo":"DEBF93FC-BA8D-4513-B4EE-A8648DA1D591@sb.org","subject":"Re: What is 'git BRANCH'?","fromName":"Jurko Gospodnetić","fromEmail":"jurko.gospodnetic@docte.hr","sentAt":"2008-07-29T22:43:35Z","receivedAt":"2008-07-29T22:43:35Z","isPatch":false,"sender":{"key":"jurko.gospodnetic@docte.hr","avatar":null},"body":"   Hi all.\n\n> On Jul 29, 2008, at 3:24 PM, Junio C Hamano wrote:\n> \n>> Jurko Gospodnetić <jurko.gospodnetic@docte.hr> writes:\n>>\n>>>  Hi.\n>>>\n>>>  I typed in \"git BRANCH\" by accident and got the error message:\n>>> \"fatal: cannot handle BRANCH internally\".\n>>>\n>>>  What does that mean?\n>>>\n>>>  It is different from the usual \"git: 'yada-yada' is not a\n>>> git-command. See 'git --help'.\" message you get when you type in an\n>>> incorrect command name.\n>>\n>> Just a guess; your git is installed on a case-challenged filesystem?\n\n   Thank you all for explaining this, and yes - this was detected on \nWindows with a NTFS drive set to case-insensitive.\n\n   But, if something is running git-branch here... why does this \nscript/executable/whatever try to check the name it got called with? Why \ndoes it not simply do its work no matter the name it got called with?\n\n   If I'm asking something to obvious here - feel free to send me back \nto read the code... :-)\n\n   Best regards,\n     Jurko Gospodnetić\n"},{"id":"85533","messageId":"bd6139dc0807291549y66c56fbah928a854f37573680@mail.gmail.com","threadId":"14745","inReplyTo":"7v63qob9hz.fsf@gitster.siamese.dyndns.org","subject":"Re: What is 'git BRANCH'?","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-07-29T22:49:00Z","receivedAt":"2008-07-29T22:49:00Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Wed, Jul 30, 2008 at 00:39, Junio C Hamano <gitster@pobox.com> wrote:\n> diff --git a/git.c b/git.c\n> index 37b1d76..c99e769 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -448,7 +448,7 @@ int main(int argc, const char **argv)\n>                cmd += 4;\n>                argv[0] = cmd;\n>                handle_internal_command(argc, argv);\n> -               die(\"cannot handle %s internally\", cmd);\n> +               help_unknown_cmd(cmd);\n>        }\n>\n>        /* Look for flags.. */\n\nWhy does handle_internal_command not complain after the \"\tfor (i = 0;\ni < ARRAY_SIZE(commands); i++) {\" that no matching commands were\nfound? Is that not an implicit assertion that would do well with being\nasserted here?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"85544","messageId":"loom.20080729T233158-95@post.gmane.org","threadId":"14745","inReplyTo":"7v63qob9hz.fsf@gitster.siamese.dyndns.org","subject":"Re: What is 'git BRANCH'?","fromName":"Eric Raible","fromEmail":"raible@gmail.com","sentAt":"2008-07-29T23:45:00Z","receivedAt":"2008-07-29T23:45:00Z","isPatch":false,"sender":{"key":"raible@gmail.com","avatar":null},"body":"Junio C Hamano <gitster <at> pobox.com> writes:\n\n> diff --git a/git.c b/git.c\n> index 37b1d76..c99e769 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -448,7 +448,7 @@ int main(int argc, const char **argv)\n>  \t\tcmd += 4;\n>  \t\targv[0] = cmd;\n>  \t\thandle_internal_command(argc, argv);\n> -\t\tdie(\"cannot handle %s internally\", cmd);\n> +\t\thelp_unknown_cmd(cmd);\n>  \t}\n\nWhich on windows leads to the less-than-friendly:\n\ngit BRANCH =>\ngit: 'BRANCH.exe' is not a git-command. See 'git --help'.\n\nI wonder if it wouldn't be better to simply to a case-insensitive\ncomparison when comparing against the builtin array.  Alternatively,\nat least the the extension (if any) ought to be stripped.\n\nI'd be glad to come up with the patch for either given the word...\n\n- Eric\n"},{"id":"85575","messageId":"20080730051453.GB4034@sigill.intra.peff.net","threadId":"14745","inReplyTo":"bd6139dc0807291549y66c56fbah928a854f37573680@mail.gmail.com","subject":"Re: What is 'git BRANCH'?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-30T05:14:53Z","receivedAt":"2008-07-30T05:14:53Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 30, 2008 at 12:49:00AM +0200, Sverre Rabbelier wrote:\n\n> Why does handle_internal_command not complain after the \"\tfor (i = 0;\n> i < ARRAY_SIZE(commands); i++) {\" that no matching commands were\n> found? Is that not an implicit assertion that would do well with being\n> asserted here?\n\nBecause it is called from two places. In one, we _know_ that this must\nbe internal, so we die right after. In the other, we try internal, then\nexternal, then alias. So we don't want to die. Grep for\nhandle_internal_cmmand in git.c.\n\n-Peff\n"}]}