Skip to content

Commit 04b6ef3

Browse files
committed
commit-graph: add new config for changed-paths & recommend it in scalar
The changed-path Bloom filters feature has proven stable and reliable over several years of use, delivering significant performance improvement for file history computation in large monorepos. Currently a user can opt-in to writing the changed-path Bloom filters using the "--changed-paths" option to "git commit-graph write". The filters will be persisted until the user drops the filters using the "--no-changed-paths" option. Large monorepos using Git's background maintenance to build and update commit-graph files could use an easy switch to enable this feature without a foreground computation. In this commit, we're proposing a new config option "commitGraph.changedPaths" - "true" value acts like "--changed-paths"; "false" disables a previous "true" config value but doesn't imply "--no-changed-paths". This config will always respect the precedence of command line option "--changed-paths" and "--no-changed-paths". We also set this new config as optional recommended config in scalar to turn on this feature for large repos. Helped-by: Derrick Stolee <[email protected]> Signed-off-by: Emily Yang <[email protected]>
1 parent 45547b6 commit 04b6ef3

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

Documentation/config/commitgraph.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ commitGraph.maxNewFilters::
88
Specifies the default value for the `--max-new-filters` option of `git
99
commit-graph write` (c.f., linkgit:git-commit-graph[1]).
1010

11+
commitGraph.changedPaths::
12+
If true, then `git commit-graph write` will compute and write
13+
changed-path Bloom filters by default, equivalent to passing
14+
`--changed-paths`. If false or unset, changed-path Bloom filters
15+
will only be written when explicitly requested via `--changed-paths`.
16+
Command-line options always take precedence over this configuration.
17+
Defaults to unset.
18+
1119
commitGraph.readChangedPaths::
1220
Deprecated. Equivalent to commitGraph.changedPathsVersion=-1 if true, and
1321
commitGraph.changedPathsVersion=0 if false. (If commitGraph.changedPathVersion

builtin/commit-graph.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ static int git_commit_graph_write_config(const char *var, const char *value,
210210
{
211211
if (!strcmp(var, "commitgraph.maxnewfilters"))
212212
write_opts.max_new_filters = git_config_int(var, value, ctx->kvi);
213+
else if (!strcmp(var, "commitgraph.changedpaths"))
214+
opts.enable_changed_paths = git_config_bool(var, value) ? 1 : -1;
213215
/*
214216
* No need to fall-back to 'git_default_config', since this was already
215217
* called in 'cmd_commit_graph()'.

scalar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static int set_recommended_config(int reconfigure)
166166
#endif
167167
/* Optional */
168168
{ "status.aheadBehind", "false" },
169+
{ "commitGraph.changedPaths", "true" },
169170
{ "commitGraph.generationVersion", "1" },
170171
{ "core.autoCRLF", "false" },
171172
{ "core.safeCRLF", "false" },

t/t5318-commit-graph.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,4 +946,47 @@ test_expect_success 'stale commit cannot be parsed when traversing graph' '
946946
)
947947
'
948948

949+
test_expect_success 'config commitGraph.changedPaths acts like --changed-paths' '
950+
git init config-changed-paths &&
951+
(
952+
cd config-changed-paths &&
953+
954+
# commitGraph.changedPaths is not set and it should not write bloom filters
955+
test_commit first &&
956+
GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
957+
test_grep ! "Bloom filters" error &&
958+
959+
# Set commitGraph.changedPaths to true and it should write bloom filters
960+
test_commit second &&
961+
git config commitGraph.changedPaths true &&
962+
GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
963+
test_grep "Bloom filters" error &&
964+
965+
# Add a config commitGraph.changedPaths as false, it should write bloom filters due to existing filters
966+
test_commit third &&
967+
git config --add commitGraph.changedPaths false &&
968+
GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
969+
test_grep "Bloom filters" error &&
970+
971+
# commitGraph.changedPaths is still false, it should respect command line precedence
972+
test_commit fourth &&
973+
GIT_PROGRESS_DELAY=0 git commit-graph write --no-changed-paths --reachable --progress 2>error &&
974+
test_grep ! "Bloom filters" error &&
975+
GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
976+
test_grep ! "Bloom filters" error &&
977+
978+
# commitGraph.changedPaths is cleared and set to false again, it should respect command line precedence
979+
test_commit fifth &&
980+
git config --unset-all commitGraph.changedPaths &&
981+
git config commitGraph.changedPaths false &&
982+
GIT_PROGRESS_DELAY=0 git commit-graph write --changed-paths --reachable --progress 2>error &&
983+
test_grep "Bloom filters" error &&
984+
985+
# commitGraph.changedPaths is still false, it should write bloom filters due to existing filters
986+
test_commit sixth &&
987+
GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
988+
test_grep "Bloom filters" error
989+
)
990+
'
991+
949992
test_done

0 commit comments

Comments
 (0)