From: Junio C Hamano Date: Tue, 3 Jun 2014 19:06:41 +0000 (-0700) Subject: Merge branch 'ym/fix-opportunistic-index-update-race' X-Git-Tag: v2.1.0-rc0~199 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9af098c29b2faa89225556258ae0e3676741c981;p=thirdparty%2Fgit.git Merge branch 'ym/fix-opportunistic-index-update-race' Read-only operations such as "git status" that internally refreshes the index write out the refreshed index to the disk to optimize future accesses to the working tree, 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. Duy raised a good point that we may need to do the same for the normal writeout codepath, not just the "opportunistic" update codepath. While that is true, nobody sane would be running two simultaneous operations that are clearly write-oriented competing with each other against the same index file. So in that sense that can be done as a less urgent follow-up for this topic. * ym/fix-opportunistic-index-update-race: read-cache.c: verify index file before we opportunistically update it wrapper.c: add xpread() similar to xread() --- 9af098c29b2faa89225556258ae0e3676741c981 diff --cc cache.h index ef4412d1c6,9244c387c3..557bd6ae81 --- a/cache.h +++ b/cache.h @@@ -292,8 -277,9 +292,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;