]> git.ipfire.org Git - thirdparty/git.git/blobdiff - midx.c
submodules: fix of regression on fetching of non-init subsub-repo
[thirdparty/git.git] / midx.c
diff --git a/midx.c b/midx.c
index e9b2e1253a678836dab68a1f15cdaf954444cfea..0de42ffdfb22c630e5b28f4997aa558c01a44d79 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -416,8 +416,12 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
        m = load_multi_pack_index(object_dir, local);
 
        if (m) {
-               m->next = r->objects->multi_pack_index;
-               r->objects->multi_pack_index = m;
+               struct multi_pack_index *mp = r->objects->multi_pack_index;
+               if (mp) {
+                       m->next = mp->next;
+                       mp->next = m;
+               } else
+                       r->objects->multi_pack_index = m;
                return 1;
        }
 
@@ -428,14 +432,11 @@ static size_t write_midx_header(struct hashfile *f,
                                unsigned char num_chunks,
                                uint32_t num_packs)
 {
-       unsigned char byte_values[4];
-
        hashwrite_be32(f, MIDX_SIGNATURE);
-       byte_values[0] = MIDX_VERSION;
-       byte_values[1] = oid_version();
-       byte_values[2] = num_chunks;
-       byte_values[3] = 0; /* unused */
-       hashwrite(f, byte_values, sizeof(byte_values));
+       hashwrite_u8(f, MIDX_VERSION);
+       hashwrite_u8(f, oid_version());
+       hashwrite_u8(f, num_chunks);
+       hashwrite_u8(f, 0); /* unused */
        hashwrite_be32(f, num_packs);
 
        return MIDX_HEADER_SIZE;