git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Concurrent modification breaks "racy git"

From
Matt McCutchen <hashproduct@gmail.com>
Date
Jun 30, 2007, 20:53 UTC
Message-ID
<3bbc18d20706301353j346ce393y8dbd9c9a755618a8@mail.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
Message 1 of 1 in “Concurrent modification breaks "racy git"”
  1. Matt McCutchenJun 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.