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

Git doesn't notice file has changed (Re: Found a "bug" in git 1.9.0 but can't reproduce it without copyrighted source code.)

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 28, 2014, 01:59 UTC
Message-ID
<20140328015921.GP15625@google.com>
In-Reply-To
<CA+fYBFcqZtCxRjAiZk24VJutc_QT5asQU8EFRKpd0ZYqoN4=1g@mail.gmail.com>

(cc-ing msysgit list, where there are more Windows-knowledgeable people) yun sheng wrote:

> On Fri, Mar 28, 2014 at 9:40 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> yun sheng wrote:
Show 24 quoted lines
>>> these two files have the same timestamp, the same size, bug slightly
>>> different contents.
>>
>> How did they get the same timestamp?
>>
>> [...]
>>> Git I'm using is msysgit 1.9.0 on windows 7
>>
>> Unixy operating systems have other fields like inode number and ctime
>> that make it possible to notice that a file might have been changed
>> without actually rereading it.  Unfortunately Git for Windows is
>> limited to what's in the WIN32_FILE_ATTRIBUTE_DATA which means the
>> size, mtime, and mode are basically all it has to go by.
>>
>> Do you know of some other Windows API call that could help?
>
> The files get the same timestamp by using `git difftool -d` to view
> diffs, the diff tool I use id beyond compare 3, this command would
> generate temp files to feed the compare program, so these files get
> the same time stamp, I copied them out from the temp folder.
>
> I have no idea of the second quesiton, I am really not familiar with
> windows API. Do you mean this file may have been changed without
> rereading and git can't detect it?

Sorry for the lack of clarity. I meant that normally git detects when a file might have been changed without actually reading the file. To do this, it uses heuristics like "If all file attributes are unchanged, the file is unchanged" which tend to work well on Unix. My question was whether there's some similar trick that could work better on Windows than the current code.

For example, if some interested person ports something like Facebook's watchman[1] to Windows[2], then Git could take advantage of that work using something like Duy's file-watcher series[3], which would be one way to fix this problem.

Thanks, Jonathan

[1] https://github.com/facebook/watchman [2] using FindFirstChangeNotification and ReadDirectoryChangesW, perhaps [3] http://thread.gmane.org/gmane.comp.version-control.git/240339/focus=241395>

Previous: yun shengNext: yun sheng
Message 5 of 7 in “Found a "bug" in git 1.9.0 but can't reproduce it without copyrighted source code.”
  1. yun shengMar 28, 2014
  2. Trần Ngọc QuânMar 28, 2014
  3. Jonathan NiederMar 28, 2014
  4. yun shengMar 28, 2014
  5. Git doesn't notice file has changed (Re: Found a "bug" in git 1.9.0 but can't reproduce it without copyrighted source code.)Jonathan Nieder, Mar 28, 2014
  6. yun shengMar 28, 2014
  7. Fwd: Found a "bug" in git 1.9.0 but can't reproduce it without copyrighted source code.yun sheng, Mar 28, 2014

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.