X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=read-cache.c;h=f83de8c4158e08bab3e0445c4d15caf2d4d105aa;hb=af9a01e1c2f6a8814b817eb7f3d78814389a3212;hp=ac9a8e7e323bb7b0728b2b199ab4f4a9bc5ce22f;hpb=cc26efb3134b28701fe65ac488af2c6abf59b21d;p=git.git diff --git a/read-cache.c b/read-cache.c index ac9a8e7e3..f83de8c41 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; } @@ -893,6 +909,15 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate, if (ce_uptodate(ce)) return ce; + /* + * CE_VALID means the user promised us that the change to + * the work tree does not matter and told us not to worry. + */ + if (!ignore_valid && (ce->ce_flags & CE_VALID)) { + ce_mark_uptodate(ce); + return ce; + } + if (lstat(ce->name, &st) < 0) { if (err) *err = errno;