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

Re: [PATCH] gitk: fix for "gitk <ambiguous-name> --"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 4, 2007, 16:58 UTC
Message-ID
<7v1wfohzs4.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<18059.31237.286280.566140@cargo.ozlabs.ibm.com>
Paul Mackerras <paulus@samba.org> writes:
> Junio: there seems to be an inconsistency between git rev-list and git
> rev-parse here.  If a name is both a filename and a ref, git rev-list
> will give a fatal error but git rev-parse will take it as a ref.
	$ rev-parse --no-revs --no-flags gitk -- gitk
	$ rev-parse --no-revs --no-flags -- gitk
should give you the path "gitk", while
	$ rev-parse --revs-only --no-flags gitk -- gitk
	$ rev-parse --revs-only --no-flags gitk --
should give you the revision (i.e. branch name) "gitk", I think.
But it is not well defined what it should do upon
	$ rev-parse --no-flags gitk
	$ rev-parse gitk

Currently they treat "gitk" as a ref. On the other hand, as you said:

	$ rev-list gitk
would error out without leading or traiing -- to disambiguate.
So you are right that they behave differently.

It might be an improvement to make rev-parse require leading or trailing -- in such a case, but I haven't thought through the ramifications of such a change. Quite a lot of existing users expect "rev-parse foo" to favor a ref "foo" over a file "foo" and give its object name.

Previous: Paul Mackerras
Message 9 of 9 in “[BUG] gitk fails with argument that is both existing directory and branch name”
  1. Uwe Kleine-KönigJul 3, 2007
  2. Johannes SchindelinJul 3, 2007
  3. Linus TorvaldsJul 3, 2007
  4. Johannes SchindelinJul 3, 2007
  5. gitk: fix for "gitk <ambiguous-name> --"Johannes Schindelin, Jul 3, 2007
  6. Gerrit PapeJul 4, 2007
  7. Uwe Kleine-KönigJul 4, 2007
  8. Paul MackerrasJul 4, 2007
  9. Junio C HamanoJul 4, 2007

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.