Merge branch 'ym/fix-opportunistic-index-update-race' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 18:49:48 +0000 (11:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 18:49:48 +0000 (11:49 -0700)
"git status", even though it is a read-only operation, tries to
update the index with refreshed lstat(2) info to optimize future
accesses to the working tree opportunistically, but this could
race with a "read-write" operation that modify the index while it
is running. Detect such a race and avoid overwriting the index.

* ym/fix-opportunistic-index-update-race:
read-cache.c: verify index file before we opportunistically update it
wrapper.c: add xpread() similar to xread()

1  2 
builtin/index-pack.c
cache.h
git-compat-util.h
read-cache.c
index 54b089542b91fe786f4f75fe363cd1d5fb1635ff,e7a6b537b4b8c9ed4310b25d4a82a14b2a7ea603..18f57de58b02de33909a40ea9720e6602cc9dcb5
@@@ -554,7 -542,7 +554,7 @@@ static void *unpack_data(struct object_
  
        do {
                ssize_t n = (len < 64*1024) ? len : 64*1024;
-               n = pread(get_thread_data()->pack_fd, inbuf, n, from);
 -              n = xpread(pack_fd, inbuf, n, from);
++              n = xpread(get_thread_data()->pack_fd, inbuf, n, from);
                if (n < 0)
                        die_errno(_("cannot pread pack file"));
                if (!n)
diff --cc cache.h
index 107ac61b68f15b1e15532c09fda9e9799f830e44,9244c387c39b3a5cf29162a36fdb1388cff9a87f..cc46be4e0fb2e8cdc69e48386f8233354a348818
+++ b/cache.h
@@@ -277,8 -277,9 +277,9 @@@ struct index_state 
        struct cache_time timestamp;
        unsigned name_hash_initialized : 1,
                 initialized : 1;
 -      struct hash_table name_hash;
 -      struct hash_table dir_hash;
 +      struct hashmap name_hash;
 +      struct hashmap dir_hash;
+       unsigned char sha1[20];
  };
  
  extern struct index_state the_index;
Simple merge
diff --cc read-cache.c
Simple merge