Skip to content

Commit b66d847

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

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ include::config/column.txt[]
340340

341341
include::config/commit.txt[]
342342

343+
include::config/commitgraph.txt[]
344+
343345
include::config/credential.txt[]
344346

345347
include::config/completion.txt[]

Documentation/config/commitgraph.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ struct commit_graph *parse_commit_graph(struct repository *r,
320320
return NULL;
321321
}
322322

323+
prepare_repo_settings(r);
324+
323325
graph = alloc_commit_graph();
324326

325327
graph->hash_len = the_hash_algo->rawsz;
@@ -396,14 +398,14 @@ struct commit_graph *parse_commit_graph(struct repository *r,
396398
case GRAPH_CHUNKID_BLOOMINDEXES:
397399
if (graph->chunk_bloom_indexes)
398400
chunk_repeated = 1;
399-
else
401+
else if (r->settings.commit_graph_read_changed_paths)
400402
graph->chunk_bloom_indexes = data + chunk_offset;
401403
break;
402404

403405
case GRAPH_CHUNKID_BLOOMDATA:
404406
if (graph->chunk_bloom_data)
405407
chunk_repeated = 1;
406-
else {
408+
else if (r->settings.commit_graph_read_changed_paths) {
407409
uint32_t hash_version;
408410
graph->chunk_bloom_data = data + chunk_offset;
409411
hash_version = get_be32(data + chunk_offset);

repo-settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ void prepare_repo_settings(struct repository *r)
1717

1818
if (!repo_config_get_bool(r, "core.commitgraph", &value))
1919
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;
2022
if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
2123
r->settings.gc_write_commit_graph = value;
2224
UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
25+
UPDATE_DEFAULT_BOOL(r->settings.commit_graph_read_changed_paths, 1);
2326
UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
2427

2528
if (!repo_config_get_int(r, "index.version", &value))

repository.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct repo_settings {
2929
int initialized;
3030

3131
int core_commit_graph;
32+
int commit_graph_read_changed_paths;
3233
int gc_write_commit_graph;
3334
int fetch_write_commit_graph;
3435

t/t4216-log-bloom.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ do
9090
"--ancestry-path side..master"
9191
do
9292
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"
9496
'
9597
done
9698
done

0 commit comments

Comments
 (0)