From: Junio C Hamano Date: Tue, 8 Jul 2008 07:19:17 +0000 (-0700) Subject: Merge branch 'lt/racy-empty' into maint X-Git-Tag: v1.5.6.3~11 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c636d0e2bcffdbd55c096944561d9ac470da600e?hp=39f319f4d51966419c0725d1145677457d6f162a Merge branch 'lt/racy-empty' into maint * lt/racy-empty: racy-git: an empty blob has a fixed object name --- diff --git a/read-cache.c b/read-cache.c index 8e5fbb6192..f83de8c415 100644 --- a/read-cache.c +++ b/read-cache.c @@ -138,6 +138,16 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st) return 0; } +static int is_empty_blob_sha1(const unsigned char *sha1) +{ + static const unsigned char empty_blob_sha1[20] = { + 0xe6,0x9d,0xe2,0x9b,0xb2,0xd1,0xd6,0x43,0x4b,0x8b, + 0x29,0xae,0x77,0x5a,0xd8,0xc2,0xe4,0x8c,0x53,0x91 + }; + + return !hashcmp(sha1, empty_blob_sha1); +} + static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) { unsigned int changed = 0; @@ -193,6 +203,12 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st) if (ce->ce_size != (unsigned int) st->st_size) changed |= DATA_CHANGED; + /* Racily smudged entry? */ + if (!ce->ce_size) { + if (!is_empty_blob_sha1(ce->sha1)) + changed |= DATA_CHANGED; + } + return changed; }