summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2008-06-23 21:22:14 -0400
committerJunio C Hamano <gitster@pobox.com>2008-06-23 21:25:20 -0700
commit1f5c74f6cf918d317c73b328dcd4cf6f55c44d8a (patch)
tree7baaadebece43244c5602da3e9a716e99c94fcdc
parent6b516d984bc72b359a14eeddfddca578cef52297 (diff)
downloadgit-1f5c74f6cf918d317c73b328dcd4cf6f55c44d8a.tar.gz
call init_pack_revindex() lazily
This makes life much easier for next patch, as well as being more efficient when the revindex is actually not used. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-pack-objects.c2
-rw-r--r--pack-check.c1
-rw-r--r--pack-revindex.c6
-rw-r--r--pack-revindex.h1
4 files changed, 4 insertions, 6 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 447d492dbb..827673ce4e 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1148,8 +1148,6 @@ static void get_object_details(void)
sorted_by_offset[i] = objects + i;
qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort);
- init_pack_revindex();
-
for (i = 0; i < nr_objects; i++)
check_object(sorted_by_offset[i]);
diff --git a/pack-check.c b/pack-check.c
index f4898732dd..b99a9171c0 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -107,7 +107,6 @@ static void show_pack_info(struct packed_git *p)
nr_objects = p->num_objects;
memset(chain_histogram, 0, sizeof(chain_histogram));
- init_pack_revindex();
for (i = 0; i < nr_objects; i++) {
const unsigned char *sha1;
diff --git a/pack-revindex.c b/pack-revindex.c
index a8aa2cd6ca..cd300bdff5 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -40,7 +40,7 @@ static int pack_revindex_ix(struct packed_git *p)
return -1 - i;
}
-void init_pack_revindex(void)
+static void init_pack_revindex(void)
{
int num;
struct packed_git *p;
@@ -118,9 +118,11 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
struct pack_revindex *rix;
struct revindex_entry *revindex;
+ if (!pack_revindex_hashsz)
+ init_pack_revindex();
num = pack_revindex_ix(p);
if (num < 0)
- die("internal error: pack revindex uninitialized");
+ die("internal error: pack revindex fubar");
rix = &pack_revindex[num];
if (!rix->revindex)
diff --git a/pack-revindex.h b/pack-revindex.h
index c3527a7565..36a514a6cf 100644
--- a/pack-revindex.h
+++ b/pack-revindex.h
@@ -6,7 +6,6 @@ struct revindex_entry {
unsigned int nr;
};
-void init_pack_revindex(void);
struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);
#endif