From: "Matt McCutchen" <hashproduct@gmail.com>
To: git@vger.kernel.org, "Petr Baudis" <pasky@suse.cz>
Subject: Concurrent modification breaks "racy git"
Date: Sat, 30 Jun 2007 16:53:12 -0400 [thread overview]
Message-ID: <3bbc18d20706301353j346ce393y8dbd9c9a755618a8@mail.gmail.com> (raw)
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
reply other threads:[~2007-06-30 20:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3bbc18d20706301353j346ce393y8dbd9c9a755618a8@mail.gmail.com \
--to=hashproduct@gmail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).