commit-graph: introduce 'commitGraph.maxNewFilters'
Introduce a configuration variable to specify a default value for the recently-introduce '--max-new-filters' option of 'git commit-graph write'. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Sep 17, 2020 at 22:59 UTC
d356d5debe56b1e43b5ca674c662a08f25176f05
4 files changed
+43
-2
Documentation/config/commitgraph.txt
+4
@@ -1,3 +1,7 @@
1
+commitGraph.maxNewFilters::
2
+ Specifies the default value for the `--max-new-filters` option of `git
3
+ commit-graph write` (c.f., linkgit:git-commit-graph[1]).
4
+
5
commitGraph.readChangedPaths::
6
If true, then git will use the changed-path Bloom filters in the
7
commit-graph file (if it exists, and they are present). Defaults to
Documentation/git-commit-graph.txt
+2
-1
@@ -71,7 +71,8 @@ With the `--max-new-filters=<n>` option, generate at most `n` new Bloom
71
filters (if `--changed-paths` is specified). If `n` is `-1`, no limit is
72
enforced. Only commits present in the new layer count against this
73
limit. To retroactively compute Bloom filters over earlier layers, it is
74
-advised to use `--split=replace`.
74
+advised to use `--split=replace`. Overrides the `commitGraph.maxNewFilters`
75
+configuration.
76
+
77
With the `--split[=<strategy>]` option, write the commit-graph as a
78
chain of multiple commit-graph files stored in
builtin/commit-graph.c
+14
@@ -181,6 +181,18 @@ static int write_option_max_new_filters(const struct option *opt,
181
return 0;
182
}
183
184
+static int git_commit_graph_write_config(const char *var, const char *value,
185
+ void *cb)
186
+{
187
+ if (!strcmp(var, "commitgraph.maxnewfilters"))
188
+ write_opts.max_new_filters = git_config_int(var, value);
189
+ /*
190
+ * No need to fall-back to 'git_default_config', since this was already
191
+ * called in 'cmd_commit_graph()'.
192
+ */
193
+ return 0;
194
+}
195
+
196
static int graph_write(int argc, const char **argv)
197
{
198
struct string_list pack_indexes = STRING_LIST_INIT_NODUP;
@@ -231,6 +243,8 @@ static int graph_write(int argc, const char **argv)
243
244
trace2_cmd_mode("write");
245
246
+ git_config(git_commit_graph_write_config, &opts);
247
+
248
argc = parse_options(argc, argv, NULL,
249
builtin_commit_graph_write_options,
250
builtin_commit_graph_write_usage, 0);
t/t4216-log-bloom.sh
+23
-1
@@ -325,13 +325,15 @@ test_expect_success 'Bloom generation is limited by --max-new-filters' '
325
'
326
327
test_expect_success 'Bloom generation backfills previously-skipped filters' '
328
+ # Check specifying commitGraph.maxNewFilters over "git config" works.
329
+ test_config -C limits commitGraph.maxNewFilters 1 &&
330
(
331
cd limits &&
332
333
rm -f trace.event &&
334
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
335
git commit-graph write --reachable --changed-paths \
334
- --split=replace --max-new-filters=1 &&
336
+ --split=replace &&
337
test_filter_computed 1 trace.event &&
338
test_filter_not_computed 4 trace.event &&
339
test_filter_trunc_empty 0 trace.event &&
@@ -339,6 +341,26 @@ test_expect_success 'Bloom generation backfills previously-skipped filters' '
341
)
342
'
343
344
+test_expect_success '--max-new-filters overrides configuration' '
345
+ git init override &&
346
+ test_when_finished "rm -fr override" &&
347
+ test_config -C override commitGraph.maxNewFilters 2 &&
348
+ (
349
+ cd override &&
350
+ test_commit one &&
351
+ test_commit two &&
352
+
353
+ rm -f trace.event &&
354
+ GIT_TRACE2_EVENT="$(pwd)/trace.event" \
355
+ git commit-graph write --reachable --changed-paths \
356
+ --max-new-filters=1 &&
357
+ test_filter_computed 1 trace.event &&
358
+ test_filter_not_computed 1 trace.event &&
359
+ test_filter_trunc_empty 0 trace.event &&
360
+ test_filter_trunc_large 0 trace.event
361
+ )
362
+'
363
+
364
test_expect_success 'Bloom generation backfills empty commits' '
365
git init empty &&
366
test_when_finished "rm -fr empty" &&