]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pack-revindex.c
Merge branch 'ab/ambiguous-object-name'
[thirdparty/git.git] / pack-revindex.c
index 70d0fbafcbf954e33b58e6fb79dd173282f59eea..08dc1601679f1011f7ff38b7a721dbb4dd116c85 100644 (file)
@@ -298,9 +298,29 @@ int load_midx_revindex(struct multi_pack_index *m)
 {
        struct strbuf revindex_name = STRBUF_INIT;
        int ret;
+
        if (m->revindex_data)
                return 0;
 
+       if (m->chunk_revindex) {
+               /*
+                * If the MIDX `m` has a `RIDX` chunk, then use its contents for
+                * the reverse index instead of trying to load a separate `.rev`
+                * file.
+                *
+                * Note that we do *not* set `m->revindex_map` here, since we do
+                * not want to accidentally call munmap() in the middle of the
+                * MIDX.
+                */
+               trace2_data_string("load_midx_revindex", the_repository,
+                                  "source", "midx");
+               m->revindex_data = (const uint32_t *)m->chunk_revindex;
+               return 0;
+       }
+
+       trace2_data_string("load_midx_revindex", the_repository,
+                          "source", "rev");
+
        get_midx_rev_filename(&revindex_name, m);
 
        ret = load_revindex_from_disk(revindex_name.buf,