]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: add new config for changed-paths & recommend it in scalar
authorEmily Yang <emilyyang.git@gmail.com>
Fri, 17 Oct 2025 20:58:59 +0000 (20:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Oct 2025 17:40:11 +0000 (10:40 -0700)
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. For this functionality, refer to 0087a87ba8
(commit-graph: persist existence of changed-paths, 2020-07-01).

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":

* If "true", "git commit-graph write" will write Bloom filters,
  equivalent to passing "--changed-paths";
* If "false" or "unset", Bloom filters will be written during "git
  commit-graph write" only if the filters already exist in the current
  commit-graph file. This matches the default behaviour of "git
  commit-graph write" without any "--[no-]changed-paths" option. Note
  "false" can disable a previous "true" config value but doesn't imply
  "--no-changed-paths".

This config will always respect the precedence of command line option
"--[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 <stolee@gmail.com>
Signed-off-by: Emily Yang <emilyyang.git@gmail.com>
Acked-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/commitgraph.adoc
Documentation/git-commit-graph.adoc
builtin/commit-graph.c
scalar.c
t/t5318-commit-graph.sh

index 7f8c9d6638f1a1291522e07aac2bed321777d435..70a56c53d2a10930d25585f7fda7065085af55f2 100644 (file)
@@ -8,6 +8,17 @@ commitGraph.maxNewFilters::
        Specifies the default value for the `--max-new-filters` option of `git
        commit-graph write` (c.f., linkgit:git-commit-graph[1]).
 
+commitGraph.changedPaths::
+       If true, then `git commit-graph write` will compute and write
+       changed-path Bloom filters by default, equivalent to passing
+       `--changed-paths`. If false or unset, changed-paths Bloom filters will
+       be written during `git commit-graph write` only if the filters already
+       exist in the current commit-graph file. This matches the default
+       behavior of `git commit-graph write` without any `--[no-]changed-paths`
+       option. To rewrite a commit-graph file without any filters, use the
+       `--no-changed-paths` option. Command-line option `--[no-]changed-paths`
+       always takes precedence over this configuration. Defaults to unset.
+
 commitGraph.readChangedPaths::
        Deprecated. Equivalent to commitGraph.changedPathsVersion=-1 if true, and
        commitGraph.changedPathsVersion=0 if false. (If commitGraph.changedPathVersion
index e9558173c001f12a53eac1eacbc3650ff0e69d02..6d19026035f96a8a9ad455ab3d1331f86006cd7a 100644 (file)
@@ -71,7 +71,7 @@ take a while on large repositories. It provides significant performance gains
 for getting history of a directory or a file with `git log -- <path>`. If
 this option is given, future commit-graph writes will automatically assume
 that this option was intended. Use `--no-changed-paths` to stop storing this
-data.
+data. `--changed-paths` is implied by config `commitGraph.changedPaths=true`.
 +
 With the `--max-new-filters=<n>` option, generate at most `n` new Bloom
 filters (if `--changed-paths` is specified). If `n` is `-1`, no limit is
index fe3ebaadadadb6966d8da799568b2ce8a6c9c7af..d62005edc0469c3523b871de51af1b478ce563c8 100644 (file)
@@ -210,6 +210,8 @@ static int git_commit_graph_write_config(const char *var, const char *value,
 {
        if (!strcmp(var, "commitgraph.maxnewfilters"))
                write_opts.max_new_filters = git_config_int(var, value, ctx->kvi);
+       else if (!strcmp(var, "commitgraph.changedpaths"))
+               opts.enable_changed_paths = git_config_bool(var, value) ? 1 : -1;
        /*
         * No need to fall-back to 'git_default_config', since this was already
         * called in 'cmd_commit_graph()'.
index 4a373c133d85622a895f310529a65a2f22473f3c..f7543116272b773f7f54f4a4638dd78a5a6f9e3e 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -166,6 +166,7 @@ static int set_recommended_config(int reconfigure)
 #endif
                /* Optional */
                { "status.aheadBehind", "false" },
+               { "commitGraph.changedPaths", "true" },
                { "commitGraph.generationVersion", "1" },
                { "core.autoCRLF", "false" },
                { "core.safeCRLF", "false" },
index 0b3404f58fe5f9d81165b7a187575525d41ed66b..98c69109632c2d7c626f23e60d70a1e48b5c9a0d 100755 (executable)
@@ -946,4 +946,48 @@ test_expect_success 'stale commit cannot be parsed when traversing graph' '
        )
 '
 
+test_expect_success 'config commitGraph.changedPaths acts like --changed-paths' '
+       git init config-changed-paths &&
+       (
+               cd config-changed-paths &&
+
+               # commitGraph.changedPaths is not set and it should not write Bloom filters
+               test_commit first &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
+               test_grep ! "Bloom filters" error &&
+
+               # Set commitGraph.changedPaths to true and it should write Bloom filters
+               test_commit second &&
+               git config commitGraph.changedPaths true &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
+               test_grep "Bloom filters" error &&
+
+               # Add one more config commitGraph.changedPaths as false to disable the previous true config value
+               # It should still write Bloom filters due to existing filters
+               test_commit third &&
+               git config --add commitGraph.changedPaths false &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
+               test_grep "Bloom filters" error &&
+
+               # commitGraph.changedPaths is still false and command line options should take precedence
+               test_commit fourth &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --no-changed-paths --reachable --progress 2>error &&
+               test_grep ! "Bloom filters" error &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
+               test_grep ! "Bloom filters" error &&
+
+               # commitGraph.changedPaths is all cleared and then set to false again, command line options should take precedence
+               test_commit fifth &&
+               git config --unset-all commitGraph.changedPaths &&
+               git config commitGraph.changedPaths false &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --changed-paths --reachable --progress 2>error &&
+               test_grep "Bloom filters" error &&
+
+               # commitGraph.changedPaths is still false and it should write Bloom filters due to existing filters
+               test_commit sixth &&
+               GIT_PROGRESS_DELAY=0 git commit-graph write --reachable --progress 2>error &&
+               test_grep "Bloom filters" error
+       )
+'
+
 test_done