Skip to content

Commit 77d13a6

Browse files
committed
packfile: skip loading index if in multi-pack-index
Signed-off-by: Derrick Stolee <[email protected]>
1 parent 9c30b70 commit 77d13a6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packfile.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,19 @@ static int open_packed_git_1(struct packed_git *p)
469469
ssize_t read_result;
470470
const unsigned hashsz = the_hash_algo->rawsz;
471471

472-
if (!p->index_data && open_pack_index(p))
473-
return error("packfile %s index unavailable", p->pack_name);
472+
if (!p->index_data) {
473+
struct multi_pack_index *m;
474+
const char *pack_name = strrchr(p->pack_name, '/');
475+
476+
for (m = the_repository->objects->multi_pack_index;
477+
m; m = m->next) {
478+
if (midx_contains_pack(m, pack_name))
479+
break;
480+
}
481+
482+
if (!m && open_pack_index(p))
483+
return error("packfile %s index unavailable", p->pack_name);
484+
}
474485

475486
if (!pack_max_fds) {
476487
unsigned int max_fds = get_max_fd_limit();
@@ -521,6 +532,10 @@ static int open_packed_git_1(struct packed_git *p)
521532
" supported (try upgrading GIT to a newer version)",
522533
p->pack_name, ntohl(hdr.hdr_version));
523534

535+
/* Skip index checking if in multi-pack-index */
536+
if (!p->index_data)
537+
return 0;
538+
524539
/* Verify the pack matches its index. */
525540
if (p->num_objects != ntohl(hdr.hdr_entries))
526541
return error("packfile %s claims to have %"PRIu32" objects"

0 commit comments

Comments
 (0)