@matheusbsbs / matheus-bagliano / commits / b66d84756f
Fork 0

commit-graph: respect 'commitGraph.readChangedPaths'

Git uses the 'core.commitGraph' configuration value to control whether or not the commit graph is used when parsing commits or performing a traversal. Now that commit-graphs can also contain a section for changed-path Bloom filters, administrators that already have commit-graphs may find it convenient to use those graphs without relying on their changed-path Bloom filters. This can happen, for example, during a staged roll-out, or in the event of an incident. Introduce 'commitGraph.readChangedPaths' to control whether or not Bloom filters are read. Note that this configuration is independent from both: - 'core.commitGraph', to allow flexibility in using all parts of a commit-graph _except_ for its Bloom filters. - The '--changed-paths' option for 'git commit-graph write', to allow reading and writing Bloom filters to be controlled independently. When the variable is set, pretend as if no Bloom data was specified at all. This avoids adding additional special-casing outside of the commit-graph internals. Suggested-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Sep 9, 2020 at 11:23 UTC b66d84756f0f3704303ddc202707ac00037ace48
6 files changed +17 -3
Documentation/config.txt
+2
@@ -340,6 +340,8 @@ include::config/column.txt[]
340
341 include::config/commit.txt[]
342
343 +include::config/commitgraph.txt[]
344 +
345 include::config/credential.txt[]
346
347 include::config/completion.txt[]
Documentation/config/commitgraph.txt new
+4
@@ -0,0 +1,4 @@
1 +commitGraph.readChangedPaths::
2 + If true, then git will use the changed-path Bloom filters in the
3 + commit-graph file (if it exists, and they are present). Defaults to
4 + true. See linkgit:git-commit-graph[1] for more information.
commit-graph.c
+4 -2
@@ -320,6 +320,8 @@ struct commit_graph *parse_commit_graph(struct repository *r,
320 return NULL;
321 }
322
323 + prepare_repo_settings(r);
324 +
325 graph = alloc_commit_graph();
326
327 graph->hash_len = the_hash_algo->rawsz;
@@ -396,14 +398,14 @@ struct commit_graph *parse_commit_graph(struct repository *r,
398 case GRAPH_CHUNKID_BLOOMINDEXES:
399 if (graph->chunk_bloom_indexes)
400 chunk_repeated = 1;
399 - else
401 + else if (r->settings.commit_graph_read_changed_paths)
402 graph->chunk_bloom_indexes = data + chunk_offset;
403 break;
404
405 case GRAPH_CHUNKID_BLOOMDATA:
406 if (graph->chunk_bloom_data)
407 chunk_repeated = 1;
406 - else {
408 + else if (r->settings.commit_graph_read_changed_paths) {
409 uint32_t hash_version;
410 graph->chunk_bloom_data = data + chunk_offset;
411 hash_version = get_be32(data + chunk_offset);
repo-settings.c
+3
@@ -17,9 +17,12 @@ void prepare_repo_settings(struct repository *r)
17
18 if (!repo_config_get_bool(r, "core.commitgraph", &value))
19 r->settings.core_commit_graph = value;
20 + if (!repo_config_get_bool(r, "commitgraph.readchangedpaths", &value))
21 + r->settings.commit_graph_read_changed_paths = value;
22 if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
23 r->settings.gc_write_commit_graph = value;
24 UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
25 + UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1);
26 UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
27
28 if (!repo_config_get_int(r, "index.version", &value))
repository.h
+1
@@ -29,6 +29,7 @@ struct repo_settings {
29 int initialized;
30
31 int core_commit_graph;
32 + int commit_graph_read_changed_paths;
33 int gc_write_commit_graph;
34 int fetch_write_commit_graph;
35
t/t4216-log-bloom.sh
+3 -1
@@ -90,7 +90,9 @@ do
90 "--ancestry-path side..master"
91 do
92 test_expect_success "git log option: $option for path: $path" '
93 - test_bloom_filters_used "$option -- $path"
93 + test_bloom_filters_used "$option -- $path" &&
94 + test_config commitgraph.readChangedPaths false &&
95 + test_bloom_filters_not_used "$option -- $path"
96 '
97 done
98 done