Skip to content

Commit d356d5d

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 809e032 commit d356d5d

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

Documentation/config/commitgraph.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
15
commitGraph.readChangedPaths::
26
If true, then git will use the changed-path Bloom filters in the
37
commit-graph file (if it exists, and they are present). Defaults to

Documentation/git-commit-graph.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ With the `--max-new-filters=<n>` option, generate at most `n` new Bloom
7171
filters (if `--changed-paths` is specified). If `n` is `-1`, no limit is
7272
enforced. Only commits present in the new layer count against this
7373
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.
7576
+
7677
With the `--split[=<strategy>]` option, write the commit-graph as a
7778
chain of multiple commit-graph files stored in

builtin/commit-graph.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ static int write_option_max_new_filters(const struct option *opt,
181181
return 0;
182182
}
183183

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+
184196
static int graph_write(int argc, const char **argv)
185197
{
186198
struct string_list pack_indexes = STRING_LIST_INIT_NODUP;
@@ -231,6 +243,8 @@ static int graph_write(int argc, const char **argv)
231243

232244
trace2_cmd_mode("write");
233245

246+
git_config(git_commit_graph_write_config, &opts);
247+
234248
argc = parse_options(argc, argv, NULL,
235249
builtin_commit_graph_write_options,
236250
builtin_commit_graph_write_usage, 0);

t/t4216-log-bloom.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,42 @@ test_expect_success 'Bloom generation is limited by --max-new-filters' '
325325
'
326326

327327
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 &&
328330
(
329331
cd limits &&
330332
331333
rm -f trace.event &&
332334
GIT_TRACE2_EVENT="$(pwd)/trace.event" \
333335
git commit-graph write --reachable --changed-paths \
334-
--split=replace --max-new-filters=1 &&
336+
--split=replace &&
335337
test_filter_computed 1 trace.event &&
336338
test_filter_not_computed 4 trace.event &&
337339
test_filter_trunc_empty 0 trace.event &&
338340
test_filter_trunc_large 0 trace.event
339341
)
340342
'
341343

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+
342364
test_expect_success 'Bloom generation backfills empty commits' '
343365
git init empty &&
344366
test_when_finished "rm -fr empty" &&

0 commit comments

Comments
 (0)