* Concurrent modification breaks "racy git"
@ 2007-06-30 20:53 Matt McCutchen
0 siblings, 0 replies; only message in thread
From: Matt McCutchen @ 2007-06-30 20:53 UTC (permalink / raw)
To: git, Petr Baudis
I found a case in which git fails to notice a modification to a file
in the working tree if the modification is concurrent with git-add.
The script below demonstrates it:
-----------
#!/bin/bash
set -x
rm -rf test
mkdir test
cd test
git-init-db
perl -e 'foreach $i (1...100) { open F, ">foo$i";
truncate F, 5000000; close F; }'
echo data1 >bar # Write bar...
git-add bar foo* &
sleep .1 # give git-add time to add it...
echo data2 >bar # and change it again in the same second!
# git-add takes a while to read foo*, so the index file gets a
# later timestamp, so git doesn't realize that bar's cleanliness
# is racy.
wait
git-diff bar # Now you don't see the difference...
touch bar
git-diff bar # Now you do!
-----------
I doubt this case will happen to anyone in practice, but I at least
wanted to make sure people knew about it. To fix it, git-add could
use a timestamp taken just before it starts reading files in place of
the mtime of the index.
Matt
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-06-30 20:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-30 20:53 Concurrent modification breaks "racy git" Matt McCutchen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).