summaryrefslogtreecommitdiff
path: root/pack-check.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-04-04 16:49:04 -0400
committerJunio C Hamano <junkio@cox.net>2007-04-05 14:59:47 -0700
commitd72308e01c5977177cda0aed06cfeee9192e1247 (patch)
treec42895d515c9bdae4d429ddd93c74b2f082fe09d /pack-check.c
parentd5ad36fe3584551a09160edce3e76d559d412ae5 (diff)
downloadgit-d72308e01c5977177cda0aed06cfeee9192e1247.tar.gz
clean up and optimize nth_packed_object_sha1() usage
Let's avoid the open coded pack index reference in pack-object and use nth_packed_object_sha1() instead. This will help encapsulating index format differences in one place. And while at it there is no reason to copy SHA1's over and over while a direct pointer to it in the index will do just fine. Signed-off-by: Nicolas Pitre <nico@cam.org> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'pack-check.c')
-rw-r--r--pack-check.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/pack-check.c b/pack-check.c
index d9883225ea..f58083d11e 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -42,13 +42,14 @@ static int verify_packfile(struct packed_git *p,
*/
nr_objects = num_packed_objects(p);
for (i = 0, err = 0; i < nr_objects; i++) {
- unsigned char sha1[20];
+ const unsigned char *sha1;
void *data;
enum object_type type;
unsigned long size;
off_t offset;
- if (nth_packed_object_sha1(p, i, sha1))
+ sha1 = nth_packed_object_sha1(p, i);
+ if (!sha1)
die("internal error pack-check nth-packed-object");
offset = find_pack_entry_one(sha1, p);
if (!offset)
@@ -82,14 +83,16 @@ static void show_pack_info(struct packed_git *p)
memset(chain_histogram, 0, sizeof(chain_histogram));
for (i = 0; i < nr_objects; i++) {
- unsigned char sha1[20], base_sha1[20];
+ const unsigned char *sha1;
+ unsigned char base_sha1[20];
const char *type;
unsigned long size;
unsigned long store_size;
off_t offset;
unsigned int delta_chain_length;
- if (nth_packed_object_sha1(p, i, sha1))
+ sha1 = nth_packed_object_sha1(p, i);
+ if (!sha1)
die("internal error pack-check nth-packed-object");
offset = find_pack_entry_one(sha1, p);
if (!offset)