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

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

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Jan 12, 2012, 17:34 UTC
Message-ID
<CACsJy8AFE0R3nfhfJkuZTkvWBmOR8+sPZDqA6SUdH17hgmTnMA@mail.gmail.com>
In-Reply-To
<20120111111831.GB15232@beez.lab.cmartin.tk>
On Wed, Jan 11, 2012 at 6:18 PM, Carlos Martín Nieto <cmn@elego.de> wrote:
Show 15 quoted lines
> Hello,
>
> 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 but tells me that RelNotes doesn't
> exist in HEAD^ which is clearly a lie (it sounds like it's a
> misunderstanding on git's part, but it's certainly not the truth).

I find Jonathan's comment [1] interesting: "Meanwhile, there is no plumbing command to compare two blobs. Strange".

I _think_ the main purpose of git diff is to compare a stage (a revision, index, worktree) with another stage, filtered by path and blob-to-blob diff is a minor thing that is needed to support "git diff <tag> <tag>" where both tags point to a tag. It'd be better to start a new command that diff between two blobs (or files in worktree/index). Something pretty close to --no-index. You would not need to mess up with setup_revisions() or verify_filename().

[1] ed84e6d (Documentation: diff can compare blobs - 2010-10-11)
-- 
Duy
Previous: Carlos Martín Nieto
Message 4 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.