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

Re: git diff <file> HEAD^:<file> error message

From
Carlos Martín Nieto <cmn@elego.de>
Date
Jan 12, 2012, 10:31 UTC
Message-ID
<20120112103152.GC11984@beez.lab.cmartin.tk>
In-Reply-To
<7vr4z54pwp.fsf@alter.siamese.dyndns.org>
On Wed, Jan 11, 2012 at 06:26:30PM -0800, Junio C Hamano wrote:
Show 23 quoted lines
> Carlos Martín Nieto <cmn@elego.de> writes:
> 
> > I was trying to figure out why running
> >
> >    git diff HEAD^:RelNotes RelNotes
> >
> > gives the expected output (on maint it tells me that the stable
> > version changed from 1.7.8.3 to 1.7.8.4) but swapping the arguments
> > doesn't.
> >
> >    git diff RelNotes HEAD^:RelNotes
> >
> > doesn't show the opposite patch ...
> 
> That comes from the general argument parsing rules of Git, namely, global
> options (e.g. --paginate) first, then subcommand name, followed by dashed
> options, revs and finally the paths. Once you give "RelNotes", which
> cannot be a rev, you cannot give a rev.
> 
> We _could_ special case the rule for "diff", but we simply didn't bother,
> as the resulting code (and the implications of special casing) would be
> too ugly to live to support such a corner case usage, especially when you
> could always say "-R" to reverse the output.

The rule "non-rev stops rev parsing" is fair enough. The error message is still very misleading, as it lies about RelNotes not being in HEAD^ and gives the impression that it was parsed as a rev (which I guess it was, but only to show the message).

   cmn
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 3 of 4 in “git diff <file> HEAD^:<file> error message”
  1. Carlos Martín NietoJan 11, 2012
  2. Junio C HamanoJan 12, 2012
  3. Carlos Martín NietoJan 12, 2012
  4. Nguyen Thai Ngoc DuyJan 12, 2012

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.