{"thread":{"id":"8787","subject":"Concurrent modification breaks \"racy git\"","startedAt":"2007-06-30T20:53:12Z","lastAt":"2007-06-30T20:53:12Z","messageCount":1,"participants":["Matt McCutchen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46129","messageId":"3bbc18d20706301353j346ce393y8dbd9c9a755618a8@mail.gmail.com","threadId":"8787","inReplyTo":null,"subject":"Concurrent modification breaks \"racy git\"","fromName":"Matt McCutchen","fromEmail":"hashproduct@gmail.com","sentAt":"2007-06-30T20:53:12Z","receivedAt":"2007-06-30T20:53:12Z","isPatch":false,"sender":{"key":"matt@mattmccutchen.net","avatar":"https://avatars.githubusercontent.com/u/8885753?v=4"},"body":"I found a case in which git fails to notice a modification to a file\nin the working tree if the modification is concurrent with git-add.\nThe script below demonstrates it:\n\n-----------\n\n#!/bin/bash\nset -x\n\nrm -rf test\nmkdir test\ncd test\n\ngit-init-db\nperl -e 'foreach $i (1...100) { open F, \">foo$i\";\n                truncate F, 5000000; close F; }'\n\necho data1 >bar # Write bar...\ngit-add bar foo* &\nsleep .1        # give git-add time to add it...\necho data2 >bar # and change it again in the same second!\n\n# git-add takes a while to read foo*, so the index file gets a\n# later timestamp, so git doesn't realize that bar's cleanliness\n# is racy.\nwait\n\ngit-diff bar # Now you don't see the difference...\n\ntouch bar\ngit-diff bar # Now you do!\n\n-----------\n\nI doubt this case will happen to anyone in practice, but I at least\nwanted to make sure people knew about it.  To fix it, git-add could\nuse a timestamp taken just before it starts reading files in place of\nthe mtime of the index.\n\nMatt\n"}]}