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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2012, 02:26 UTC
Message-ID
<7vr4z54pwp.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120111111831.GB15232@beez.lab.cmartin.tk>
Carlos Martín Nieto <cmn@elego.de> writes:
Show 11 quoted lines
> 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.

Previous: Carlos Martín NietoNext: Carlos Martín Nieto
Message 2 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.