From d1af002dc608be3213ba18df1a99ced0ab42e6d6 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 20 May 2005 16:59:17 -0400 Subject: [PATCH] delta check This adds knowledge of delta objects to fsck-cache and various object parsing code. A new switch to git-fsck-cache is provided to display the maximum delta depth found in a repository. Signed-off-by: Nicolas Pitre Signed-off-by: Linus Torvalds --- object.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index b5a62e7f87..deb683076d 100644 --- a/object.c +++ b/object.c @@ -4,6 +4,7 @@ #include "commit.h" #include "cache.h" #include "tag.h" +#include "delta.h" #include #include @@ -104,6 +105,7 @@ struct object *parse_object(unsigned char *sha1) unsigned long mapsize; void *map = map_sha1_file(sha1, &mapsize); if (map) { + int is_delta; struct object *obj; char type[100]; unsigned long size; @@ -111,9 +113,14 @@ struct object *parse_object(unsigned char *sha1) munmap(map, mapsize); if (!buffer) return NULL; - if (check_sha1_signature(sha1, buffer, size, type) < 0) + is_delta = !strcmp(type, "delta"); + if (!is_delta && check_sha1_signature(sha1, buffer, size, type) < 0) printf("sha1 mismatch %s\n", sha1_to_hex(sha1)); - if (!strcmp(type, "blob")) { + if (is_delta) { + struct delta *delta = lookup_delta(sha1); + parse_delta_buffer(delta, buffer, size); + obj = (struct object *) delta; + } else if (!strcmp(type, "blob")) { struct blob *blob = lookup_blob(sha1); parse_blob_buffer(blob, buffer, size); obj = &blob->object; -- cgit v1.2.3