summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
authorDerrick Stolee <stolee@gmail.com>2018-07-12 19:39:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-20 18:27:28 (GMT)
commitc4d25228ebb22a60f1fcb267e19c503bab708cdc (patch)
tree8367a0857c798421013fae47e8006cdab8d5a4af /midx.c
parent662148c4356620f6567b0a689602079339ebadb7 (diff)
downloadgit-c4d25228ebb22a60f1fcb267e19c503bab708cdc.zip
git-c4d25228ebb22a60f1fcb267e19c503bab708cdc.tar.gz
git-c4d25228ebb22a60f1fcb267e19c503bab708cdc.tar.bz2
config: create core.multiPackIndex setting
The core.multiPackIndex config setting controls the multi-pack- index (MIDX) feature. If false, the setting will disable all reads from the multi-pack-index file. Read this config setting in the new prepare_multi_pack_index_one() which is called during prepare_packed_git(). This check is run once per repository. Add comparison commands in t5319-multi-pack-index.sh to check typical Git behavior remains the same as the config setting is turned on and off. This currently includes 'git rev-list' and 'git log' commands to trigger several object database reads. Currently, these would only catch an error in the prepare_multi_pack_index_one(), but with later commits will catch errors in object lookups, abbreviations, and approximate object counts. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/midx.c b/midx.c
index e83110a..4090cf4 100644
--- 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)