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

Re: "git diff-files" command reports differences that don't exist

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 5, 2021, 21:49 UTC
Message-ID
<xmqqa6rh9sph.fsf@gitster.c.googlers.com>
In-Reply-To
<4210f5f1-dd7e-f425-6ab2-e220a33e82bf@discourse.org>
Michael Brown <michael.brown@discourse.org> writes:
Show 7 quoted lines
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> 1. Be in any existing repository in a clean state (I tested with 2 existing
>    repositories and 1 completely fresh)
> 1. run `git diff-files`, see no output
> 1. touch an existing file: `touch a`
> 1. run `git diff-files`

This is totally expected behaviour. In general when you are working with plumbing commands like diff-files and diff-index, you are expected to do "update-index --refresh" upfront.

A plumbing command "git diff" has an equivalent of "update-index --refresh" built into it, but the plumbing commands are designed to be used in scripts, and in order to allow scripting programmers to avoid making unnecessary "update-index --refresh", e.g.

	git update-index --refresh
	git diff-files | use diff-files output
	git diff-index | use diff-index output

they leave it the responsibility of the calling script (or the end user who directly use them from the command line) to refresh the cached stat information as necessary.

Previous: Michael BrownNext: Eric Sunshine
Message 2 of 5 in “"git diff-files" command reports differences that don't exist”
  1. Michael BrownMar 5, 2021
  2. Junio C HamanoMar 5, 2021
  3. Eric SunshineMar 5, 2021
  4. Junio C HamanoMar 5, 2021
  5. Michael BrownMar 5, 2021

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.