Re: touching a file causes it to be listed using git diff-files
- From
Jeff King <peff@peff.net>
- Date
- Jan 14, 2010, 06:39 UTC
- Message-ID
- <20100114063939.GA17565@coredump.intra.peff.net>
- In-Reply-To
- <p06240813c77462aa2cfb@[63.138.152.134]>
On Thu, Jan 14, 2010 at 12:57:05AM -0500, Stephen Bannasch wrote:
Show 10 quoted lines
> >> 'git diff' also stats the files but strangely 'git diff --quiet' doesn't ??? > > > >I can't reproduce that behavior here on the current "master". Old > >versions of git used to not do the index refresh for "diff". What > >version of git are you using? > > The most recent test was on: > > $ git --version > git version 1.6.6
Ah, OK, I figured it out. It is due to the early return of "--quiet". Since we know we are simply returning a status of "all the same" or "at least one difference", we can quit after finding the first difference.
So if you have two files, "a" and "b", you can try:
$ touch a $ echo changes >b $ git diff --quiet $ git diff-files
and you will see that 'a' has been updated, because we traverse the files in sorted order and quit only after seeing 'b'.
But if you do instead:
$ touch b $ echo change >a $ git diff --quiet $ git diff-files
we quit after 'a' and never refresh 'b'.
I don't think it should be considered a bug, though. "git diff" produces the correct result, and it is under no obligation to produce its side effect. If a caller really wants the index refreshed, he should use update-index instead.
-Peff