summaryrefslogtreecommitdiff
path: root/builtin/multi-pack-index.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-09-14 22:06:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-14 23:34:18 (GMT)
commitcaca3c9f07f90645e32c284c88c379109abf59be (patch)
tree257c33a005692de96e61d8e6a2df0d09554b3eb7 /builtin/multi-pack-index.c
parent8de300e1f7ebe7099ce6ce60f6c6fb494e6703b2 (diff)
downloadgit-caca3c9f07f90645e32c284c88c379109abf59be.zip
git-caca3c9f07f90645e32c284c88c379109abf59be.tar.gz
git-caca3c9f07f90645e32c284c88c379109abf59be.tar.bz2
midx.c: respect 'pack.writeBitmapHashcache' when writing bitmaps
In the previous commit, the bitmap writing code learned to propagate values from an existing hash-cache extension into the bitmap that it is writing. Now that that functionality exists, let's expose it by teaching the 'git multi-pack-index' builtin to respect the `pack.writeBitmapHashCache` option so that the hash-cache may be written at all. Two minor points worth noting here: - The 'git multi-pack-index write' sub-command didn't previously read any configuration (instead this is handled in the base command). A separate handler is added here to respect this write-specific config option. - I briefly considered adding a 'bitmap_flags' field to the static options struct, but decided against it since it would require plumbing through a new parameter to the write_midx_file() function. Instead, a new MIDX-specific flag is added, which is translated to the corresponding bitmap one. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/multi-pack-index.c')
-rw-r--r--builtin/multi-pack-index.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 73c0113..578ffea 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -61,6 +61,23 @@ static struct option *add_common_options(struct option *prev)
return parse_options_concat(common_opts, prev);
}
+static int git_multi_pack_index_write_config(const char *var, const char *value,
+ void *cb)
+{
+ if (!strcmp(var, "pack.writebitmaphashcache")) {
+ if (git_config_bool(var, value))
+ opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE;
+ else
+ opts.flags &= ~MIDX_WRITE_BITMAP_HASH_CACHE;
+ }
+
+ /*
+ * We should never make a fall-back call to 'git_default_config', since
+ * this was already called in 'cmd_multi_pack_index()'.
+ */
+ return 0;
+}
+
static int cmd_multi_pack_index_write(int argc, const char **argv)
{
struct option *options;
@@ -73,6 +90,10 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
OPT_END(),
};
+ opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE;
+
+ git_config(git_multi_pack_index_write_config, NULL);
+
options = add_common_options(builtin_multi_pack_index_write_options);
trace2_cmd_mode(argv[0]);