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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 14, 2010 at 12:57:05AM -0500, Stephen Bannasch wrote:

> >> '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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]