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

Re: touching a file causes it to be listed using git diff-files

From
Jeff King <peff@peff.net>
Date
Jan 14, 2010, 03:02 UTC
Message-ID
<20100114030204.GB1878@coredump.intra.peff.net>
In-Reply-To
<p0624080ec7740ddc4caf@[63.138.152.134]>
On Wed, Jan 13, 2010 at 06:57:28PM -0500, Stephen Bannasch wrote:
Show 5 quoted lines
> If I touch a file in the working directory (only changing it's last-modified) attribute it shows up when running git diff-files.
> 
> If I then run git status followed by git diff-files again it doesn't show up either time.
> 
> Is this an error?

No. For performance reasons[1], plumbing commands like diff-files do not update the index. You must run "git update-index --refresh" manually.

User-facing porcelain commands like "git diff" and "git status" will refresh the index automatically. So "git status" will, as a side effect, refresh the index and impact further calls to diff-files.

-Peff

[1] Refreshing the index needs to stat all of the files. If you are writing a script using plumbing commands, you probably want to do the possibly-expensive refresh once at the start of your script, and then issue many diff commands. This makes a lot of sense for "diff-index", which otherwise does not need to touch the working tree at all. I'm not sure how much it helps with diff-files, though, which clearly ends up stat'ing the working tree file anyway.

Previous: Stephen BannaschNext: Stephen Bannasch
Message 2 of 6 in “touching a file causes it to be listed using git diff-files”
  1. Stephen BannaschJan 13, 2010
  2. Jeff KingJan 14, 2010
  3. Stephen BannaschJan 14, 2010
  4. Jeff KingJan 14, 2010
  5. Stephen BannaschJan 14, 2010
  6. Jeff KingJan 14, 2010

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.