Am 05.02.2015 um 20:17 schrieb Sebastian Schuberth:
> On Thursday, February 5, 2015 at 7:14:52 PM UTC+1, Johannes Sixt wrote:
>
>>> I found a strange problem in msysGit, I am wondering if it's a bug.
>>> I already discussed it here:
>>>
https://groups.google.com/forum/#!msg/git-users/9K0ExTQpMF8/Z3BkgiA3HJUJ
>>> It seems not to happen in Git for Linux or OS-X.
>>> The problem occurs in msysGit 1.9.0 and 1.9.5 (running x86 version on a
>>> Windows 7 x64 system).
>>>
>>> Essentially, the problem seems that Git for Windows assumes that two
>>> files are the same when both the timestamp and the file size match.
>>> Obviously the file contents is not inspected nor the hash recalculated.
>>
>>That's correct. Git on Windows does not notice such a change.
Don't panic! In practice, this doesn't seem to be a major problem during
interactive work.
However, if there are many changes in quick succession, induced by a
script, as in the case of the OP, chances are much higher that a change
is missed.
>> On POSIX,
>>we have the inode number as an additional indication to notice that the
>>file was updated, but on Windows we do not (the "inode" number is always
>>zero).
>>
>>We could evaluate similar information that is present on Windows file
>>systems, but it just has not been implemented. So, if it is a real itch
>>for you, please, by all means, scratch it ;-)
>
> Wow, that was totally new to be and sort of destroys my world picture of
> Git ... I always thought Git is tracking file *contents*, and nothing else.
>
> Hannes, could you elaborate how tracking the inode helps to solve this
> issue on Windows? I always though the inodes also to not change when a
> file is changed without changing its size. (Sorry, I don't now much
> really about inodes or Linux file systems in general.)
The information comparable to inodes on Windows are the members
.nFileIndexLow and .nFileIndexHigh of struct BY_HANDLE_FILE_INFORMATION
retrievable by GetFileInformationByHandle(). (Perhaps there is a
function that retrieves the same information given a path name instead
of a handle.)
BTW, notice this difference between upstream Git and Git for Windows
that exists because of the mentioned weakness:
diff --git a/t/t4130-apply-criss-cross-rename.sh
b/t/t4130-apply-criss-cross-rename.sh
index d173acd..bf7049e 100755
--- a/t/t4130-apply-criss-cross-rename.sh
+++ b/t/t4130-apply-criss-cross-rename.sh
@@ -14,8 +14,8 @@ create_file() {
test_expect_success 'setup' '
create_file file1 "File1 contents" &&
- create_file file2 "File2 contents" &&
- create_file file3 "File3 contents" &&
+ create_file file2 "File2 more contents" &&
+ create_file file3 "File3 even more contents" &&
git add file1 file2 file3 &&
git commit -m 1
'
The test case exchanges two files such that only the inode number is
modified. On Windows, git would not detect that the index is outdated
because of the unusable inode value. With this patch, the file size
changes and it notices the outdated index.
-- Hannes