summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3205364)
raw | patch | inline | side by side (parent: 3205364)
author | Nicolas Pitre <nico@cam.org> | |
Wed, 16 Jul 2008 06:31:37 +0000 (02:31 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 16 Jul 2008 16:33:28 +0000 (09:33 -0700) |
The coming index format change doesn't allow for the number of objects
to be determined from the size of the index file directly. Instead, Let's
initialize a field in the packed_git structure with the object count when
the index is validated since the count is always known at that point.
(based on commit 57059091fad25427bce9b3d47e073ce0518d164b)
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to be determined from the size of the index file directly. Instead, Let's
initialize a field in the packed_git structure with the object count when
the index is validated since the count is always known at that point.
(based on commit 57059091fad25427bce9b3d47e073ce0518d164b)
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-count-objects.c | patch | blob | history | |
builtin-pack-objects.c | patch | blob | history | |
cache.h | patch | blob | history | |
fsck-objects.c | patch | blob | history | |
pack-check.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
sha1_name.c | patch | blob | history |
index 73c59824238f58c2dc94544ef67ea51741d834ac..7795a635fe079d4bd233d9da6817700cd8f87e79 100644 (file)
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
for (p = packed_git; p; p = p->next) {
if (!p->pack_local)
continue;
- packed += num_packed_objects(p);
+ packed += p->num_objects;
}
printf("count: %lu\n", loose);
printf("size: %lu\n", loose_size / 2);
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 4c345d5d6c7dc5acf6c323f40e5b109ae7e1c24b..b9c3da2cd11d1852285bf4718bdc3b451d2b361d 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
static void prepare_pack_revindex(struct pack_revindex *rix)
{
struct packed_git *p = rix->p;
- int num_ent = num_packed_objects(p);
+ int num_ent = p->num_objects;
int i;
const char *index = p->index_data;
prepare_pack_revindex(rix);
revindex = rix->revindex;
lo = 0;
- hi = num_packed_objects(p) + 1;
+ hi = p->num_objects + 1;
do {
int mi = (lo + hi) / 2;
if (revindex[mi].offset == ofs) {
index 191c738ed96abd747185e1b40f6d34f566ac7b48..1bcc7c131eee5451f030218446398eaf88f2852c 100644 (file)
--- a/cache.h
+++ b/cache.h
unsigned long pack_size;
const void *index_data;
void *pack_base;
+ unsigned int num_objects;
int index_version;
unsigned int pack_last_used;
unsigned int pack_use_cnt;
extern int use_packed_git(struct packed_git *);
extern void unuse_packed_git(struct packed_git *);
extern struct packed_git *add_packed_git(char *, int, int);
-extern int num_packed_objects(const struct packed_git *p);
extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, unsigned int);
extern unsigned long find_pack_entry_one(const unsigned char *, struct packed_git *);
extern void *unpack_entry_gently(struct packed_git *, unsigned long, char *, unsigned long *);
diff --git a/fsck-objects.c b/fsck-objects.c
index f6015a80f90d96f1897597aa2b86465427b2272c..bdbca543a72d2d7de959bd948add02e6e9cf593b 100644 (file)
--- a/fsck-objects.c
+++ b/fsck-objects.c
verify_pack(p, 0);
for (p = packed_git; p; p = p->next) {
- int num = num_packed_objects(p);
+ int num = p->num_objects;
for (i = 0; i < num; i++)
fsck_sha1(nth_packed_object_sha1(p, i));
}
diff --git a/pack-check.c b/pack-check.c
index 11f6ed2117fbe5bded2408d82742fa4b724b54de..578f59e61e29215ba6d04fd084eac801d6523b9a 100644 (file)
--- a/pack-check.c
+++ b/pack-check.c
return error("Packfile version %d unsupported",
ntohl(hdr->hdr_version));
nr_objects = ntohl(hdr->hdr_entries);
- if (num_packed_objects(p) != nr_objects)
+ if (p->num_objects != nr_objects)
return error("Packfile claims to have %d objects, "
"while idx size expects %d", nr_objects,
- num_packed_objects(p));
+ p->num_objects);
/* Check integrity of pack data with its SHA-1 checksum */
SHA1_Init(&ctx);
diff --git a/sha1_file.c b/sha1_file.c
index b4c5209d6511f201fa133ec70cb6349379491373..9c40e7e1dda6b105fcd079ad388cabc1ad32a3ac 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
p->index_version = 1;
p->index_data = idx_map;
p->index_size = idx_size;
+ p->num_objects = nr;
return 0;
}
}
}
-int num_packed_objects(const struct packed_git *p)
-{
- /* See check_packed_git_idx() */
- return (p->index_size - 20 - 20 - 4*256) / 24;
-}
-
const unsigned char *nth_packed_object_sha1(const struct packed_git *p,
unsigned int n)
{
const unsigned char *index = p->index_data;
index += 4 * 256;
- if (num_packed_objects(p) <= n)
+ if (n >= p->num_objects)
return NULL;
return index + 24 * n + 4;
}
diff --git a/sha1_name.c b/sha1_name.c
index d083096e2043301f189c456336a85bb4064e232e..be9be5290dfd0369625138fd71c45f3754ca2e1b 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
prepare_packed_git();
for (p = packed_git; p && found < 2; p = p->next) {
- unsigned num = num_packed_objects(p);
+ unsigned num = p->num_objects;
unsigned first = 0, last = num;
while (first < last) {
unsigned mid = (first + last) / 2;