summaryrefslogtreecommitdiff
path: root/packfile.c
diff options
context:
space:
mode:
authorDerrick Stolee <stolee@gmail.com>2018-07-12 19:39:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-20 18:27:29 (GMT)
commit17c35c89698c1b9e130ae9a3dc9c016b353308d8 (patch)
treedfb340c553556c5da84075e141eb4fe688a3c43a /packfile.c
parentf3a002bd84790e89399c3a18f1e7101b850ed6f8 (diff)
downloadgit-17c35c89698c1b9e130ae9a3dc9c016b353308d8.zip
git-17c35c89698c1b9e130ae9a3dc9c016b353308d8.tar.gz
git-17c35c89698c1b9e130ae9a3dc9c016b353308d8.tar.bz2
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>
Diffstat (limited to 'packfile.c')
-rw-r--r--packfile.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/packfile.c b/packfile.c
index 2c819a0..e6ecf12 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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();
@@ -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"