From: Junio C Hamano Date: Wed, 25 Jun 2014 18:49:48 +0000 (-0700) Subject: Merge branch 'ym/fix-opportunistic-index-update-race' into maint X-Git-Tag: v2.0.1~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1881d2b88c4b889dcb95782ad4bc5395808438e9 Merge branch 'ym/fix-opportunistic-index-update-race' into maint "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() --- 1881d2b88c4b889dcb95782ad4bc5395808438e9 diff --cc builtin/index-pack.c index 54b089542b,e7a6b537b4..18f57de58b --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@@ -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 107ac61b68,9244c387c3..cc46be4e0f --- a/cache.h +++ 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;