# Concurrent modification breaks "racy git"

1 messages from 2007-06-30 to 2007-06-30. Participants: Matt McCutchen.
Thread: https://gitlist.dev/t/8787

## Matt McCutchen, 2007-06-30 20:53

Subject: Concurrent modification breaks "racy git"
Message-ID: <3bbc18d20706301353j346ce393y8dbd9c9a755618a8@mail.gmail.com>
URL: https://gitlist.dev/e/3bbc18d20706301353j346ce393y8dbd9c9a755618a8%40mail.gmail.com

```
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

```
