{"thread":{"id":"39921","subject":"Git doesn't detect change, if file modification time is restored to original one","startedAt":"2015-07-23T07:29:07Z","lastAt":"2015-07-23T17:32:31Z","messageCount":7,"participants":["Konrád Lőrinczi","Sebastian Schuberth","Johannes Schindelin","Konstantin Khomoutov","Karsten Blees","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"266648","messageId":"CABEDGg8zixeab-CsviAU-fNE1Jmi0ZWbN6=e6Q+-XK3eFv6djA@mail.gmail.com","threadId":"39921","inReplyTo":null,"subject":"Git doesn't detect change, if file modification time is restored to original one","fromName":"Konrád Lőrinczi","fromEmail":"klorinczi@gmail.com","sentAt":"2015-07-23T07:29:07Z","receivedAt":"2015-07-23T07:29:07Z","isPatch":false,"sender":{"key":"klorinczi@gmail.com","avatar":null},"body":"I wrote a search & replace perl script, which recursively searches\nfiles and replaces text in them. After replace, it restores original\nmodification time (mtime) of file.\n\nInteresting, that git status doesn't show replaced changes, if the\nmtime is same as original.\n\nIs there a way to force git status to show changes, even if the file\ndates are the same?\n\n\nI tried to set core to:\n    trustctime = false\n    checkStat = minimal\nUnfortunately the change is still not detected :(\nIt seems isn't a way to force fallback to file checking and completely\nignore file modification date :(\n\n\nAny idea?\n\n\nThanks,\nKonrad Lorinczi\n"},{"id":"266649","messageId":"55B09E95.4000700@gmail.com","threadId":"39921","inReplyTo":"CABEDGg8zixeab-CsviAU-fNE1Jmi0ZWbN6=e6Q+-XK3eFv6djA@mail.gmail.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2015-07-23T07:58:13Z","receivedAt":"2015-07-23T07:58:13Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On 7/23/2015 9:29, Konrád Lőrinczi wrote:\n\n> Interesting, that git status doesn't show replaced changes, if the\n> mtime is same as original.\n\nSee the somewhat related FAQ entry at [1] and also the lengthy discussion at [2] about a similar issue. That said, deleting the .git/index file should make these files appear as modified.\n\n[1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F\n[2] https://github.com/msysgit/git/issues/312\n\nRegards,\nSebastian\n"},{"id":"266651","messageId":"CABEDGg_R49K61wiV9SsTnLS9SztHDjEQhOHjwzYn2JJwrrb-KA@mail.gmail.com","threadId":"39921","inReplyTo":"55B09E95.4000700@gmail.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Konrád Lőrinczi","fromEmail":"klorinczi@gmail.com","sentAt":"2015-07-23T09:14:11Z","receivedAt":"2015-07-23T09:14:11Z","isPatch":false,"sender":{"key":"klorinczi@gmail.com","avatar":null},"body":"Based on [1] I found some solutions which makes the changed files\nappear again as changed:\na) touch -m --date=01/01/1980 .git/index\nSo it is a touch, but only a single one, instead of touching all the\nfiles in the work dir.\n\nb) git read-tree HEAD\nAlso working well.\n\n\nI accept these solutions as workarounds, but the real solution would be:\nDev suggestions:\n1) Add a --force-reread option to git status, so user can force reread tree.\ngit status --force-reread\n\n2) Add status.force-reread (true or false) option to .git/config so\nuser can set this variable permanently for a repo.\nstatus.force-reread = false (should be default)\n\n\nCould be possible to implement 1) and 2) features to next git release?\n\n\nThanks,\nKonrad Lorinczi\n\n\n[1] https://github.com/msysgit/git/issues/312\n\n2015-07-23 9:58 GMT+02:00 Sebastian Schuberth <sschuberth@gmail.com>:\n> On 7/23/2015 9:29, Konrád Lőrinczi wrote:\n>\n>> Interesting, that git status doesn't show replaced changes, if the\n>> mtime is same as original.\n>\n> See the somewhat related FAQ entry at [1] and also the lengthy discussion at [2] about a similar issue. That said, deleting the .git/index file should make these files appear as modified.\n>\n> [1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F\n> [2] https://github.com/msysgit/git/issues/312\n>\n> Regards,\n> Sebastian\n>\n"},{"id":"266658","messageId":"ae5d01d5685d9db4cedcada1ce58f71d@www.dscho.org","threadId":"39921","inReplyTo":"CABEDGg8zixeab-CsviAU-fNE1Jmi0ZWbN6=e6Q+-XK3eFv6djA@mail.gmail.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-07-23T14:17:08Z","receivedAt":"2015-07-23T14:17:08Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn 2015-07-23 09:29, Konrád Lőrinczi wrote:\n> I wrote a search & replace perl script, which recursively searches\n> files and replaces text in them. After replace, it restores original\n> modification time (mtime) of file.\n\nSince this is almost identical to https://github.com/msysgit/git/issues/312#issuecomment-124030520 I assume that you wrote that.\n\nIn my answer on the (already closed) GitHub ticket, I wrote this:\n\n-- snipsnap --\n\n\n    I wrote a search & replace perl script, which recursively searches\n    files and replaces text in them. After replace, it restores original\n    modification time (mtime) of file.\n\nBy this \"restoring\" of the original modification time you broke the contract: the mtime should reflect the time of the latest change. You replaced something, i.e. changed the file contents. Git expects the mtime to be adjusted in that case. By painstakingly faking it back to its original value you essentially told Git: don't worry, this file has not changed since you last saw it.\n\nThere is nothing Git can do to outguess you when you go out of your way to break the most fundamental promise of the mtime value.\n"},{"id":"266660","messageId":"20150723175342.77f635820fb9f1b69a73d39a@domain007.com","threadId":"39921","inReplyTo":"CABEDGg_R49K61wiV9SsTnLS9SztHDjEQhOHjwzYn2JJwrrb-KA@mail.gmail.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2015-07-23T14:53:42Z","receivedAt":"2015-07-23T14:53:42Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Thu, 23 Jul 2015 11:14:11 +0200\nKonrád Lőrinczi <klorinczi@gmail.com> wrote:\n\n[...]\n> I accept these solutions as workarounds, but the real solution would\n> be: Dev suggestions:\n> 1) Add a --force-reread option to git status, so user can force\n> reread tree. git status --force-reread\n> \n> 2) Add status.force-reread (true or false) option to .git/config so\n> user can set this variable permanently for a repo.\n> status.force-reread = false (should be default)\n> \n> Could be possible to implement 1) and 2) features to next git release?\n\nCould you explain what's your real use case with preserving mtimes\nwhile changing the files?  I mean, implementing \"mtime-stability\"\nin your tools appears to be a good excersize in programming but what\nreal-world problem does it solve?\n\nI'm asking because if you are not going to implement the changes to\nGit you suggested yourself, then someone else should be *convinced* to\ndo so.  So far, your trouble appears to be too artifical to bother.\n"},{"id":"266661","messageId":"55B1053D.7030006@gmail.com","threadId":"39921","inReplyTo":"20150723175342.77f635820fb9f1b69a73d39a@domain007.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2015-07-23T15:16:13Z","receivedAt":"2015-07-23T15:16:13Z","isPatch":false,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 23.07.2015 um 16:53 schrieb Konstantin Khomoutov:\n> On Thu, 23 Jul 2015 11:14:11 +0200\n> Konrád Lőrinczi <klorinczi@gmail.com> wrote:\n> \n> [...]\n>> I accept these solutions as workarounds, but the real solution would\n>> be: Dev suggestions:\n>> 1) Add a --force-reread option to git status, so user can force\n>> reread tree. git status --force-reread\n>>\n>> 2) Add status.force-reread (true or false) option to .git/config so\n>> user can set this variable permanently for a repo.\n>> status.force-reread = false (should be default)\n>>\n>> Could be possible to implement 1) and 2) features to next git release?\n> \n> Could you explain what's your real use case with preserving mtimes\n> while changing the files?  I mean, implementing \"mtime-stability\"\n> in your tools appears to be a good excersize in programming but what\n> real-world problem does it solve?\n> \n\nI'd like to add that this is not a git-specific problem: resetting mtime\non purpose will fool lots of programs, including backup software, file\nsynchronization tools (rsync, xcopy /D), build systems (make), and web\nservers / proxies (If-Modified-Since requests).\n\nSo you would typically reset mtime if you *want* programs to ignore the\nchanges.\n"},{"id":"266672","messageId":"xmqqsi8epyog.fsf@gitster.dls.corp.google.com","threadId":"39921","inReplyTo":"55B1053D.7030006@gmail.com","subject":"Re: Git doesn't detect change, if file modification time is restored to original one","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-23T17:32:31Z","receivedAt":"2015-07-23T17:32:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> I'd like to add that this is not a git-specific problem: resetting mtime\n> on purpose will fool lots of programs, including backup software, file\n> synchronization tools (rsync, xcopy /D), build systems (make), and web\n> servers / proxies (If-Modified-Since requests).\n>\n> So you would typically reset mtime if you *want* programs to ignore the\n> changes.\n\nYup.  Nicely phrased.\n\nWhen you run a wholesale rewrite of many files, often you find that\nsome (or many) of the files did not have to be modified.  E.g.\n\"perl -i -e 's/old/new/' *\" may want to touch all files, but the\nfiles that did not have string 'old' in them would have the same\ncontents as before.  In such a case, you can avoid unnecessary\nreinspection of contents (e.g. recompilation) by many tools that pay\nattention to mtime to see if contents changed by reverting mtime to\nthe original for files that did not change.\n\nGit also pays attention to fields other than mtime, so after\n\n    perl -i -e 's/old/ancient/' *\n\nand reverting mtime even for ones that got changed, we should notice\nthe changes.  But you are correct that such an abuse of \"touch\" will\nbreak many other tools.\n"}]}