]> git.ipfire.org Git - thirdparty/git.git/commitdiff
midx: pass a repository pointer
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 29 Apr 2019 16:18:55 +0000 (09:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 May 2019 04:48:41 +0000 (13:48 +0900)
Much of the multi-pack-index code focuses on the multi_pack_index
struct, and so we only pass a pointer to the current one. However,
we will insert a dependency on the packed_git linked list in a
future change, so we will need a repository reference. Inserting
these parameters is a significant enough change to split out.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/multi-pack-index.c
builtin/pack-objects.c
midx.c
midx.h
packfile.c

index ae6e476ad567e57e5a1e308d7901b0a0c331640f..72dfd3dadc7bf8037d4bd11d24aabca6a56a5fa8 100644 (file)
@@ -46,7 +46,7 @@ int cmd_multi_pack_index(int argc, const char **argv,
        if (!strcmp(argv[0], "write"))
                return write_midx_file(opts.object_dir);
        if (!strcmp(argv[0], "verify"))
-               return verify_midx_file(opts.object_dir);
+               return verify_midx_file(the_repository, opts.object_dir);
 
        die(_("unrecognized verb: %s"), argv[0]);
 }
index 2d9a3bdc9d83e24759b5a8892c26863bd9829c34..e606b9ef033005d7238184a95ae79dd4aed2c182 100644 (file)
@@ -1078,7 +1078,7 @@ static int want_object_in_pack(const struct object_id *oid,
 
        for (m = get_multi_pack_index(the_repository); m; m = m->next) {
                struct pack_entry e;
-               if (fill_midx_entry(oid, &e, m)) {
+               if (fill_midx_entry(the_repository, oid, &e, m)) {
                        struct packed_git *p = e.p;
                        off_t offset;
 
diff --git a/midx.c b/midx.c
index d5d2e9522fe39dc1032df4dcdea34e0eb3c741fb..8b8faec35afbdc272c8838e3f238cc034c4938a4 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -201,7 +201,7 @@ void close_midx(struct multi_pack_index *m)
        FREE_AND_NULL(m->pack_names);
 }
 
-int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id)
+int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id)
 {
        struct strbuf pack_name = STRBUF_INIT;
 
@@ -261,7 +261,10 @@ static uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos)
        return get_be32(m->chunk_object_offsets + pos * MIDX_CHUNK_OFFSET_WIDTH);
 }
 
-static int nth_midxed_pack_entry(struct multi_pack_index *m, struct pack_entry *e, uint32_t pos)
+static int nth_midxed_pack_entry(struct repository *r,
+                                struct multi_pack_index *m,
+                                struct pack_entry *e,
+                                uint32_t pos)
 {
        uint32_t pack_int_id;
        struct packed_git *p;
@@ -271,7 +274,7 @@ static int nth_midxed_pack_entry(struct multi_pack_index *m, struct pack_entry *
 
        pack_int_id = nth_midxed_pack_int_id(m, pos);
 
-       if (prepare_midx_pack(m, pack_int_id))
+       if (prepare_midx_pack(r, m, pack_int_id))
                die(_("error preparing packfile from multi-pack-index"));
        p = m->packs[pack_int_id];
 
@@ -301,14 +304,17 @@ static int nth_midxed_pack_entry(struct multi_pack_index *m, struct pack_entry *
        return 1;
 }
 
-int fill_midx_entry(const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m)
+int fill_midx_entry(struct repository * r,
+                   const struct object_id *oid,
+                   struct pack_entry *e,
+                   struct multi_pack_index *m)
 {
        uint32_t pos;
 
        if (!bsearch_midx(oid, m, &pos))
                return 0;
 
-       return nth_midxed_pack_entry(m, e, pos);
+       return nth_midxed_pack_entry(r, m, e, pos);
 }
 
 /* Match "foo.idx" against either "foo.pack" _or_ "foo.idx". */
@@ -1020,7 +1026,7 @@ static int compare_pair_pos_vs_id(const void *_a, const void *_b)
                        display_progress(progress, _n); \
        } while (0)
 
-int verify_midx_file(const char *object_dir)
+int verify_midx_file(struct repository *r, const char *object_dir)
 {
        struct pair_pos_vs_id *pairs = NULL;
        uint32_t i;
@@ -1034,7 +1040,7 @@ int verify_midx_file(const char *object_dir)
        progress = start_progress(_("Looking for referenced packfiles"),
                                  m->num_packs);
        for (i = 0; i < m->num_packs; i++) {
-               if (prepare_midx_pack(m, i))
+               if (prepare_midx_pack(r, m, i))
                        midx_report("failed to load pack in position %d", i);
 
                display_progress(progress, i + 1);
@@ -1099,7 +1105,7 @@ int verify_midx_file(const char *object_dir)
 
                nth_midxed_object_oid(&oid, m, pairs[i].pos);
 
-               if (!fill_midx_entry(&oid, &e, m)) {
+               if (!fill_midx_entry(r, &oid, &e, m)) {
                        midx_report(_("failed to load pack entry for oid[%d] = %s"),
                                    pairs[i].pos, oid_to_hex(&oid));
                        continue;
diff --git a/midx.h b/midx.h
index 26dd042d6381336bfd576ab769509f674c364d08..3eb29731f2b1e8e96a116a683fd8baad1020a46b 100644 (file)
--- a/midx.h
+++ b/midx.h
@@ -5,6 +5,7 @@
 
 struct object_id;
 struct pack_entry;
+struct repository;
 
 #define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
 
@@ -37,18 +38,18 @@ struct multi_pack_index {
 };
 
 struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local);
-int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id);
+int prepare_midx_pack(struct repository *r, struct multi_pack_index *m, uint32_t pack_int_id);
 int bsearch_midx(const struct object_id *oid, struct multi_pack_index *m, uint32_t *result);
 struct object_id *nth_midxed_object_oid(struct object_id *oid,
                                        struct multi_pack_index *m,
                                        uint32_t n);
-int fill_midx_entry(const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
+int fill_midx_entry(struct repository *r, const struct object_id *oid, struct pack_entry *e, struct multi_pack_index *m);
 int midx_contains_pack(struct multi_pack_index *m, const char *idx_or_pack_name);
 int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local);
 
 int write_midx_file(const char *object_dir);
 void clear_midx_file(struct repository *r);
-int verify_midx_file(const char *object_dir);
+int verify_midx_file(struct repository *r, const char *object_dir);
 
 void close_midx(struct multi_pack_index *m);
 
index cdf6b6ec3443cfe3fcabb55a4475a9fc64c8543b..7b94a14726d0641e24c5248502e11933472da890 100644 (file)
@@ -1035,7 +1035,7 @@ struct packed_git *get_all_packs(struct repository *r)
                for (m = r->objects->multi_pack_index; m; m = m->next) {
                        uint32_t i;
                        for (i = 0; i < m->num_packs; i++) {
-                               if (!prepare_midx_pack(m, i)) {
+                               if (!prepare_midx_pack(r, m, i)) {
                                        m->packs[i]->next = p;
                                        p = m->packs[i];
                                }
@@ -1998,7 +1998,7 @@ int find_pack_entry(struct repository *r, const struct object_id *oid, struct pa
                return 0;
 
        for (m = r->objects->multi_pack_index; m; m = m->next) {
-               if (fill_midx_entry(oid, e, m))
+               if (fill_midx_entry(r, oid, e, m))
                        return 1;
        }