git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What is 'git BRANCH'?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 29, 2008, 22:39 UTC
Message-ID
<7v63qob9hz.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vej5cba6z.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Jurko Gospodnetić <jurko.gospodnetic@docte.hr> writes:
>
>>   Hi.
>>
>>   I typed in "git BRANCH" by accident and got the error message:
>> "fatal: cannot handle BRANCH internally".
>>
>>   What does that mean?
>>
>>   It is different from the usual "git: 'yada-yada' is not a
>> git-command. See 'git --help'." message you get when you type in an
>> incorrect command name.
>
> Just a guess; your git is installed on a case-challenged filesystem?

Yeah, that must be it. This can happen on MacOS and Windows, I would imagine.

-- >8 -- [PATCH] Fail on unknown command sensibly on case-challenged filesystems

The callchain on a case-challenged filesystem when the user runs "git BRANCH" looks like this:

  - main(): git BRANCH
   - execv_dashed_external("BRANCH")
    - execvp("git-BRANCH")
     - main(): git-BRANCH
      - prefixcmp("git-BRANCH", "git-")
       - handle_internal_command()
         struct cmd_struct commands[] does not have "BRANCH"
         so it returns, instead of exiting.

When the "git wrapper" execs "git-BRANCH", if your filesystem knows "branch" and "BRANCH" are different, execvp() would fail and we will see the familiar error message from the git.c::main().

However, if execvp() succeeds, we feed an unknown command name to handle_internal_command() and it triggers a different error message.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 37b1d76..c99e769 100644
--- a/git.c
+++ b/git.c
@@ -448,7 +448,7 @@ int main(int argc, const char **argv)
 		cmd += 4;
 		argv[0] = cmd;
 		handle_internal_command(argc, argv);
-		die("cannot handle %s internally", cmd);
+		help_unknown_cmd(cmd);
 	}
 
 	/* Look for flags.. */
Previous: Jurko GospodnetićNext: Sverre Rabbelier
Message 5 of 8 in “What is 'git BRANCH'?”
  1. Jurko GospodnetićJul 29, 2008
  2. Junio C HamanoJul 29, 2008
  3. Kevin BallardJul 29, 2008
  4. Jurko GospodnetićJul 29, 2008
  5. Junio C HamanoJul 29, 2008
  6. Sverre RabbelierJul 29, 2008
  7. Jeff KingJul 30, 2008
  8. Eric RaibleJul 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.