diff options
author | Junio C Hamano <junkio@cox.net> | 2005-06-27 03:34:06 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 15:27:51 -0700 |
commit | 36e4d74a210ba618e1520f11ce7fc2f8baec5bb8 (patch) | |
tree | bbcd071ad589fe301eb7246ede689f8cd9839080 /pack-objects.c | |
parent | c4584ae3fd7cd595a638a07dfd853e9d2745e930 (diff) | |
download | git-36e4d74a210ba618e1520f11ce7fc2f8baec5bb8.tar.gz |
[PATCH] Enhance sha1_file_size() into sha1_object_info()
This lets us eliminate one use of map_sha1_file() outside
sha1_file.c, to bring us one step closer to the packed GIT.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'pack-objects.c')
-rw-r--r-- | pack-objects.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/pack-objects.c b/pack-objects.c index 102af3054b..62ed265437 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -160,28 +160,22 @@ static void add_object_entry(unsigned char *sha1, unsigned int hash) static void check_object(struct object_entry *entry) { - char buffer[128]; - char type[10]; - unsigned long mapsize; - z_stream stream; - void *map; - - map = map_sha1_file(entry->sha1, &mapsize); - if (!map) - die("unable to map %s", sha1_to_hex(entry->sha1)); - if (unpack_sha1_header(&stream, map, mapsize, buffer, sizeof(buffer)) < 0) - die("unable to unpack %s header", sha1_to_hex(entry->sha1)); - munmap(map, mapsize); - if (parse_sha1_header(buffer, type, &entry->size) < 0) - die("unable to parse %s header", sha1_to_hex(entry->sha1)); - if (!strcmp(type, "commit")) { - entry->type = OBJ_COMMIT; - } else if (!strcmp(type, "tree")) { - entry->type = OBJ_TREE; - } else if (!strcmp(type, "blob")) { - entry->type = OBJ_BLOB; - } else - die("unable to pack object %s of type %s", sha1_to_hex(entry->sha1), type); + char type[20]; + + if (!sha1_object_info(entry->sha1, type, &entry->size)) { + if (!strcmp(type, "commit")) { + entry->type = OBJ_COMMIT; + } else if (!strcmp(type, "tree")) { + entry->type = OBJ_TREE; + } else if (!strcmp(type, "blob")) { + entry->type = OBJ_BLOB; + } else + die("unable to pack object %s of type %s", + sha1_to_hex(entry->sha1), type); + } + else + die("unable to get type of object %s", + sha1_to_hex(entry->sha1)); } static void get_object_details(void) |