config: create core.multiPackIndex setting
[git/git.git] / midx.c
diff --git a/midx.c b/midx.c
index e83110a..4090cf4 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "csum-file.h"
 #include "dir.h"
 #include "lockfile.h"
@@ -177,6 +178,30 @@ cleanup_fail:
        return NULL;
 }
 
+int prepare_multi_pack_index_one(struct repository *r, const char *object_dir)
+{
+       struct multi_pack_index *m = r->objects->multi_pack_index;
+       struct multi_pack_index *m_search;
+       int config_value;
+
+       if (repo_config_get_bool(r, "core.multipackindex", &config_value) ||
+           !config_value)
+               return 0;
+
+       for (m_search = m; m_search; m_search = m_search->next)
+               if (!strcmp(object_dir, m_search->object_dir))
+                       return 1;
+
+       r->objects->multi_pack_index = load_multi_pack_index(object_dir);
+
+       if (r->objects->multi_pack_index) {
+               r->objects->multi_pack_index->next = m;
+               return 1;
+       }
+
+       return 0;
+}
+
 static size_t write_midx_header(struct hashfile *f,
                                unsigned char num_chunks,
                                uint32_t num_packs)