author | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Jun 2008 21:34:20 +0000 (14:34 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Jun 2008 21:34:20 +0000 (14:34 -0700) |
* lt/racy-empty:
racy-git: an empty blob has a fixed object name
racy-git: an empty blob has a fixed object name
read-cache.c | patch | blob | history |
diff --git a/read-cache.c b/read-cache.c
index 8e5fbb619295fe3e4d950e8926d8034d6f825e41..f83de8c4158e08bab3e0445c4d15caf2d4d105aa 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
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;
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;
}