summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-06-22 14:34:20 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-22 14:34:20 -0700
commit159e639e5bf24d78b22802934ae335413b2aa6ae (patch)
treee9de4646d9151b96b49de2a5e01e03f8ca0b8c87 /read-cache.c
parent6b8791982cec5b4ccc7874a83624af8596a5f2fe (diff)
parentf49c2c22fef520fd69ff26869c26dc58a834de2c (diff)
downloadgit-159e639e5bf24d78b22802934ae335413b2aa6ae.tar.gz
Merge branch 'lt/racy-empty'
* lt/racy-empty: racy-git: an empty blob has a fixed object name
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c16
1 files changed, 16 insertions, 0 deletions
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;
}