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

Re: git diff-files weirdness (bug?)

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 23, 2008, 16:50 UTC
Message-ID
<alpine.LFD.1.10.0805230942480.3081@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.10.0805230906110.3081@woody.linux-foundation.org>
On Fri, 23 May 2008, Linus Torvalds wrote:
> 
> And I think "setup_diff_no_index()" is broken exactly because it sees that 
> '--' and then totally ignores it and says "if I see two paths, we'll say 
> it's the non-index case".

Actually, I think it's broken not so much because it ignores '--', but because it's just way too eager to do the "non-git" case.

Basically, it is trying to act like a traditional "diff", but in doing so it disables the normal "git diff" semantics. Which is incorrect, when you actually _want_ the normal "git diff" behaviour.

So I would suggest that we make it *much* harder to trigger the "make it act like a traditional 'diff'" thing.

I would suggest that we *not* invoce the traditional 'diff' behaviour when:

 - we're called as "git-diff-files". That's clearly a git thing. Don't try 
   to make it act like an external non-git diff. Only do the special case 
   for plain "git diff" itself.
 - even for plain "git diff", make it much harder to trigger non-git 
   behaviour. Don't do it if the files don't exist. Don't do it if there 
   is '--' there.

In fact, maybe we should remove that thing entirely, or *require* a flag to enable it (at least if we're in a git directory). It's a cute hack, but when the cute hack actually makes it impossible to do certain real git operations, it's a cute hack that is detrimental.

		Linus
Previous: Linus TorvaldsNext: Johannes Schindelin
Message 3 of 11 in “git diff-files weirdness (bug?)”
  1. Catalin MarinasMay 23, 2008
  2. Linus TorvaldsMay 23, 2008
  3. Linus TorvaldsMay 23, 2008
  4. diff -- file1 file2: do not default to --no-index inside a git repositoryJohannes Schindelin, May 23, 2008
  5. diff file1 file2: do not default to --no-index inside a git repositoryJohannes Schindelin, May 23, 2008
  6. Junio C HamanoMay 24, 2008
  7. 1/3 tests: do not use implicit "git diff --no-index"Junio C Hamano, May 24, 2008
  8. 2/3 diff-files: do not play --no-index gamesJunio C Hamano, May 24, 2008
  9. 3/3 "git diff": do not ignore index without --no-indexJunio C Hamano, May 24, 2008
  10. Junio C HamanoMay 24, 2008
  11. Junio C HamanoMay 24, 2008

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.