{"action":"created","issue":{"url":"https://api.github.com/repos/msysgit/git/issues/312","labels_url":"https://api.github.com/repos/msysgit/git/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/msysgit/git/issues/312/comments","events_url":"https://api.github.com/repos/msysgit/git/issues/312/events","html_url":"https://github.com/msysgit/git/issues/312","id":56685461,"number":312,"title":"Git does not see that file in working directory differs from HEAD ","user":{"login":"j66st","id":10867890,"avatar_url":"https://avatars.githubusercontent.com/u/10867890?v=3","gravatar_id":"","url":"https://api.github.com/users/j66st","html_url":"https://github.com/j66st","followers_url":"https://api.github.com/users/j66st/followers","following_url":"https://api.github.com/users/j66st/following{/other_user}","gists_url":"https://api.github.com/users/j66st/gists{/gist_id}","starred_url":"https://api.github.com/users/j66st/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j66st/subscriptions","organizations_url":"https://api.github.com/users/j66st/orgs","repos_url":"https://api.github.com/users/j66st/repos","events_url":"https://api.github.com/users/j66st/events{/privacy}","received_events_url":"https://api.github.com/users/j66st/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-02-05T15:35:28Z","updated_at":"2015-02-06T16:12:39Z","closed_at":null,"body":"I found a strange problem in msysGit, I am wondering if it's a bug.\r\nI already discussed it here:\r\nhttps://groups.google.com/forum/#!topic/msysgit/6XLoSPH26kc\r\nYou can download my Demo.zip attachment there.\r\nIt seems not to happen in Git for Linux or OS-X.\r\nThe problem occurs in msysGit 1.9.0 and 1.9.5 (running x86 version on a Windows 7 x64 system).\r\n\r\nEssentially, 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.\r\n\r\nAs mentioned I created a minimal demo package to easily prove the issue. Simply download the zip file, put it in a clean directory and run the enclosed script from bash. Below is a transcript of what happens when I run the script in my situation.\r\n\r\nThe issue is a real show-stopper in my automated migration from Visual SourceSafe to Git (in a test transferring 20,000 source files the problem caused loss of roughly 0.1% of the files from the history), so I hope for a quick solution.\r\n\r\n``` ShellSession\r\nWelcome to Git (version 1.9.5-preview20141217)\r\n\r\n\r\nRun 'git help git' to display the help index.\r\nRun 'git help <command>' to display help for specific commands.\r\n\r\njoostadm@MUPC20 ~\r\n$ cd /d/proj/try/git\r\n\r\njoostadm@MUPC20 /d/proj/try/git\r\n$ ls -l\r\ntotal 15\r\n-rw-r--r--    1 joostadm Administ    26968 Jan 23 18:43 DixiLink2.zip\r\n-rwxr-xr-x    1 joostadm Administ     1848 Feb  5 14:05 weird-git-demo\r\n\r\njoostadm@MUPC20 /d/proj/try/git\r\n$ weird-git-demo\r\nNote: No argument supplied, using DemoRepo by default.\r\n+ mkdir DemoRepo\r\n+ cd DemoRepo\r\n+ unzip ../DixiLink2.zip\r\nArchive:  ../DixiLink2.zip\r\n   creating: .git/\r\n extracting: .git/COMMIT_EDITMSG\r\n  inflating: .git/config\r\n  inflating: .git/description\r\n  inflating: .git/gitk.cache\r\n extracting: .git/HEAD\r\n   creating: .git/hooks/\r\n  inflating: .git/hooks/applypatch-msg.sample\r\n  inflating: .git/hooks/commit-msg.sample\r\n  inflating: .git/hooks/post-update.sample\r\n  inflating: .git/hooks/pre-applypatch.sample\r\n  inflating: .git/hooks/pre-commit.sample\r\n  inflating: .git/hooks/pre-push.sample\r\n  inflating: .git/hooks/pre-rebase.sample\r\n  inflating: .git/hooks/prepare-commit-msg.sample\r\n  inflating: .git/hooks/update.sample\r\n  inflating: .git/index\r\n   creating: .git/info/\r\n  inflating: .git/info/exclude\r\n   creating: .git/logs/\r\n  inflating: .git/logs/HEAD\r\n   creating: .git/logs/refs/\r\n   creating: .git/logs/refs/heads/\r\n  inflating: .git/logs/refs/heads/master\r\n   creating: .git/objects/\r\n   creating: .git/objects/29/\r\n extracting: .git/objects/29/c51bbb9ada43dbe98cbd5dbedbab56586b24c3\r\n   creating: .git/objects/68/\r\n extracting: .git/objects/68/b1f129eb06b91fc6c9a3885fc0d24ad0cdaa50\r\n   creating: .git/objects/7e/\r\n extracting: .git/objects/7e/8d94849a38370141b3ca2aab5c3cadc27934da\r\n   creating: .git/objects/cf/\r\n extracting: .git/objects/cf/13dbb766d4aff04ad51d3cdac84fda67dc6f50\r\n   creating: .git/objects/da/\r\n extracting: .git/objects/da/eca6b50a218a78e4cca5566965381e2d384b7f\r\n   creating: .git/objects/de/\r\n extracting: .git/objects/de/3643596c73be4f6112d027616c8df31acd1b09\r\n   creating: .git/objects/ec/\r\n extracting: .git/objects/ec/88fb155c5e9ebd8b3ead39345618517c0af6cf\r\n   creating: .git/objects/info/\r\n   creating: .git/objects/pack/\r\n   creating: .git/refs/\r\n   creating: .git/refs/heads/\r\n extracting: .git/refs/heads/master\r\n   creating: .git/refs/tags/\r\n extracting: .git/refs/tags/2011-11-24\r\n  inflating: dixilinkerr.h\r\n+ echo 'This repository now contains version 1 and 2 of dixilinkerr.h:'\r\nThis repository now contains version 1 and 2 of dixilinkerr.h:\r\n+ git log\r\ncommit cf13dbb766d4aff04ad51d3cdac84fda67dc6f50\r\nAuthor: Joost <joost@localhost>\r\nDate:   Tue Sep 11 09:57:32 2007 +0000\r\n\r\n    @VSS 11-09-2007 11:08:35 [Edit] dixilinkerr.h\r\n\r\ncommit de3643596c73be4f6112d027616c8df31acd1b09\r\nAuthor: Joost <joost@localhost>\r\nDate:   Fri Jul 6 12:27:57 2007 +0000\r\n\r\n    @VSS 01-06-2007 01:54:53 [Create] dixilinkerr.h\r\n+ echo 'Version 3 is in our working directory:'\r\nVersion 3 is in our working directory:\r\n+ head -n 12 dixilinkerr.h\r\n// DixiLinkErr.h\r\n\r\n#pragma once\r\n\r\n#ifndef EXCPCAT_DIXILINK\r\n#define EXCPCAT_DIXILINK 2000\r\n#endif\r\n\r\n#ifndef __DixiLinkErr_H_INCLUDED__\r\n#define __DixiLinkErr_H_INCLUDED__\r\n\r\n#ifndef IDL_ENUM\r\n+ echo 'The file in our HEAD'\r\nThe file in our HEAD\r\n+ git show HEAD:dixilinkerr.h\r\n+ head -n 12\r\n// DixiLinkErr.h\r\n\r\n#pragma once\r\n\r\n#ifndef CAT_DIXILINK_ERR\r\n#define CAT_DIXILINK_ERR 2000\r\n#endif\r\n\r\n#ifndef __DixiLinkErr_H_INCLUDED__\r\n#define __DixiLinkErr_H_INCLUDED__\r\n\r\n#ifndef IDL_ENUM\r\n+ echo 'You see? Working copy differs from HEAD.'\r\nYou see? Working copy differs from HEAD.\r\n+ echo 'So the working directory is dirty, right? Ask Git:'\r\nSo the working directory is dirty, right? Ask Git:\r\n+ git status\r\nOn branch master\r\nnothing to commit, working directory clean\r\n+ git diff\r\n+ echo 'In my situation, Git sees no difference here, I THINK THIS IS WRONG!'\r\nIn my situation, Git sees no difference here, I THINK THIS IS WRONG!\r\n+ echo 'So we are unable to add version 3 of our file. Let'\\''s try it once again:'\r\nSo we are unable to add version 3 of our file. Let's try it once again:\r\n+ git add dixilinkerr.h\r\n+ git status\r\nOn branch master\r\nnothing to commit, working directory clean\r\n+ echo 'In my situation at this point there is nothing to add or commit.'\r\nIn my situation at this point there is nothing to add or commit.\r\n+ echo 'End of demo'\r\nEnd of demo\r\n\r\njoostadm@MUPC20 /d/proj/try/git\r\n$ \r\n```"},"comment":{"url":"https://api.github.com/repos/msysgit/git/issues/comments/73261556","html_url":"https://github.com/msysgit/git/issues/312#issuecomment-73261556","issue_url":"https://api.github.com/repos/msysgit/git/issues/312","id":73261556,"user":{"login":"j66st","id":10867890,"avatar_url":"https://avatars.githubusercontent.com/u/10867890?v=3","gravatar_id":"","url":"https://api.github.com/users/j66st","html_url":"https://github.com/j66st","followers_url":"https://api.github.com/users/j66st/followers","following_url":"https://api.github.com/users/j66st/following{/other_user}","gists_url":"https://api.github.com/users/j66st/gists{/gist_id}","starred_url":"https://api.github.com/users/j66st/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j66st/subscriptions","organizations_url":"https://api.github.com/users/j66st/orgs","repos_url":"https://api.github.com/users/j66st/repos","events_url":"https://api.github.com/users/j66st/events{/privacy}","received_events_url":"https://api.github.com/users/j66st/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T16:12:39Z","updated_at":"2015-02-06T16:12:39Z","body":"@t-b: Re 100 ns timestamp resolution: that's only in theory. The clock ticks at a slower pace and a file system like FAT can only store seconds. Re changing code: I don't have an environment right now to rebuild git for Windows, nor the time to dive into the code, so I leave that to others.\r\n@kblees Indeed I guess that the problem could be caused by extracting files from VSS will restore their original mtime (but don't call that \"messing up\"). Restore of a backup would do so too. But Git seems not prepared to that: the file in the working directory will be older than Git's index file, probably that's the reason Git looks no further and assumes that the file is stale. I wish there would be an option to turn off this reasoning; I want a command switch (and a config setting) to bypass this caching and force Git to not use the mtime as a factor in determining file change.\r\n\r\nI really wished that Git could preserve timestamps too! I'm so used to seeing a file's age in the directory listing and being able to sort out which files were changed this week, etc.. Everyone moving from VSS to Git (or TFS, for that matter) is complaining about the loss of this information. I changed the vss2git tool to keep this information at least in the commit message.\r\nSo I'm not \"playing around\" with mtimes, that's what Git is doing. I consider them valuable. Backup software ought to keep an index for itself which files it saved last time in order to do incrementals. Otherwise files copied from another medium would never be backed up.\r\n\r\n@YueLinHo Using git reset --mixed after extracting the file and before the git add is not a workaround. I tried it, Git still does not see the file as changed. But just touching the file \r\nwould be sufficient, I guess. So that the working copy is never older than Git's index.\r\n\r\n"}}