diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-09-08 14:22:34 +0700 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2013-09-13 21:00:28 -0400 |
commit | fd44c36e7babd096f4566c03a0780454c3fac2f5 (patch) | |
tree | 3415af6df7ac4b7f121079679f554512b50e4ffb | |
parent | bcddb6c2cf06823a861cf6593e6e9bcadaf03d1e (diff) | |
download | git-fd44c36e7babd096f4566c03a0780454c3fac2f5.tar.gz |
index-pack: make sure all objects are registered in v4's SHA-1 table
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
-rw-r--r-- | builtin/index-pack.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 84e29127d6..dc5711b82d 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -288,6 +288,19 @@ static inline void *fill_and_use(int bytes) return p; } +static void check_against_sha1table(const unsigned char *sha1) +{ + const unsigned char *found; + if (!packv4) + return; + + found = bsearch(sha1, sha1_table, nr_objects, 20, + (int (*)(const void *, const void *))hashcmp); + if (!found) + die(_("object %s not found in SHA-1 table"), + sha1_to_hex(sha1)); +} + static NORETURN void bad_object(unsigned long offset, const char *format, ...) __attribute__((format (printf, 2, 3))); @@ -907,6 +920,7 @@ static void resolve_delta(struct object_entry *delta_obj, bad_object(delta_obj->idx.offset, _("failed to apply delta")); hash_sha1_file(result->data, result->size, typename(delta_obj->real_type), delta_obj->idx.sha1); + check_against_sha1table(delta_obj->idx.sha1); sha1_object(result->data, NULL, result->size, delta_obj->real_type, delta_obj->idx.sha1); counter_lock(); @@ -1104,8 +1118,12 @@ static void parse_pack_objects(unsigned char *sha1) /* large blobs, check later */ obj->real_type = OBJ_BAD; nr_delays++; - } else - sha1_object(data, NULL, obj->size, obj->type, obj->idx.sha1); + check_against_sha1table(obj->idx.sha1); + } else { + check_against_sha1table(obj->idx.sha1); + sha1_object(data, NULL, obj->size, obj->type, + obj->idx.sha1); + } free(data); display_progress(progress, i+1); } |