packfile: skip loading index if in multi-pack-index
Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jul 12, 2018 at 15:39 UTC
17c35c89698c1b9e130ae9a3dc9c016b353308d8
1 file changed
+17
-2
packfile.c
+17
-2
@@ -469,8 +469,19 @@ static int open_packed_git_1(struct packed_git *p)
469
ssize_t read_result;
470
const unsigned hashsz = the_hash_algo->rawsz;
471
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
+ }
485
486
if (!pack_max_fds) {
487
unsigned int max_fds = get_max_fd_limit();
@@ -521,6 +532,10 @@ static int open_packed_git_1(struct packed_git *p)
532
" supported (try upgrading GIT to a newer version)",
533
p->pack_name, ntohl(hdr.hdr_version));
534
535
+ /* Skip index checking if in multi-pack-index */
536
+ if (!p->index_data)
537
+ return 0;
538
+
539
/* Verify the pack matches its index. */
540
if (p->num_objects != ntohl(hdr.hdr_entries))
541
return error("packfile %s claims to have %"PRIu32" objects"