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

Re: [PATCH] bisect: improve error message when branch checkout fails

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 5, 2009, 09:46 UTC
Message-ID
<7vskknv3ec.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20090404220226.58a3ac99.chriscool@tuxfamily.org>
Christian Couder <chriscool@tuxfamily.org> writes:
Show 19 quoted lines
> In "git-bisect.sh" the "git checkout" command is only used to
> change the current branch, but it is used like this:
>
> git checkout "$branch"
>
> which will output the following misleading error message when
> it fails:
>
> error: pathspec 'foo' did not match any file(s) known to git.
>
> This patch change the way we use "git checkout" like this:
>
> git checkout "$branch" --
>
> so that we will get the following error message:
>
> fatal: invalid reference: foo
>
> which is better.
Thanks; will apply.

But I think "git checkout" should either say "unknown branch" (assuming that most people switch branches, not detach HEAD), or "no such commit" (which could be a bit confusing for people who have not even heard of detached HEAD, but may be more technically correct).

"Invalid reference" does not help anybody and is not technically correct, either. A git newbie would say "Huh? what is a ref?" and a git savvy would say "I admit I made a typo, but you, the git checkout command, are supposed to take an arbitrary commit object, not necessarily a ref".

Previous: Christian Couder
Message 2 of 2 in “bisect: improve error message when branch checkout fails”
  1. bisect: improve error message when branch checkout failsChristian Couder, Apr 4, 2009
  2. Junio C HamanoApr 5, 2009

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.