Skip to content

Commit

Permalink
packfile: skip loading index if in multi-pack-index
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
derrickstolee authored and gitster committed Jul 20, 2018
1 parent f3a002b commit 17c35c8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,19 @@ static int open_packed_git_1(struct packed_git *p)
ssize_t read_result;
const unsigned hashsz = the_hash_algo->rawsz;

if (!p->index_data && open_pack_index(p))
return error("packfile %s index unavailable", p->pack_name);
if (!p->index_data) {
struct multi_pack_index *m;
const char *pack_name = strrchr(p->pack_name, '/');

for (m = the_repository->objects->multi_pack_index;
m; m = m->next) {
if (midx_contains_pack(m, pack_name))
break;
}

if (!m && open_pack_index(p))
return error("packfile %s index unavailable", p->pack_name);
}

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

/* Skip index checking if in multi-pack-index */
if (!p->index_data)
return 0;

/* Verify the pack matches its index. */
if (p->num_objects != ntohl(hdr.hdr_entries))
return error("packfile %s claims to have %"PRIu32" objects"
Expand Down

0 comments on commit 17c35c8

Please sign in to comment.