summaryrefslogtreecommitdiff
path: root/builtin-fsck.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 /builtin-fsck.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 'builtin-fsck.c')
-rw-r--r--builtin-fsck.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 21f1f9e91d..4e5aa33dfb 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -348,7 +348,7 @@ static int fsck_tag(struct tag *tag)
return 0;
}
-static int fsck_sha1(unsigned char *sha1)
+static int fsck_sha1(const unsigned char *sha1)
{
struct object *obj = parse_object(sha1);
if (!obj) {
@@ -648,11 +648,8 @@ int cmd_fsck(int argc, char **argv, const char *prefix)
for (p = packed_git; p; p = p->next) {
uint32_t i, num = num_packed_objects(p);
- for (i = 0; i < num; i++) {
- unsigned char sha1[20];
- nth_packed_object_sha1(p, i, sha1);
- fsck_sha1(sha1);
- }
+ for (i = 0; i < num; i++)
+ fsck_sha1(nth_packed_object_sha1(p, i));
}
}