diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2021-02-25 18:19:43 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-25 15:10:41 -0800 |
commit | 702110aac63556b4572d9c7b65c9123ec8038ebf (patch) | |
tree | c189e072d9b4c54ad167e98ff9432a8ef4cf2ed6 /commit-graph.c | |
parent | c7ef8fe608819f05526408c741719589599a544a (diff) | |
download | git-702110aac63556b4572d9c7b65c9123ec8038ebf.tar.gz |
commit-graph: use config to specify generation type
We have two established generation number versions:
1: topological levels
2: corrected commit dates
The corrected commit dates are enabled by default, but they also write
extra data in the GDAT and GDOV chunks. Services that host Git data
might want to have more control over when this feature rolls out than
just updating the Git binaries.
Add a new "commitGraph.generationVersion" config option that specifies
the intended generation number version. If this value is less than 2,
then the GDAT chunk is never written _or read_ from an existing file.
This can replace our use of the GIT_TEST_COMMIT_GRAPH_NO_GDAT
environment variable in the test suite. Remove it.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r-- | commit-graph.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/commit-graph.c b/commit-graph.c index 8b07a9a0a6..1e9b88c003 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -96,6 +96,13 @@ define_commit_slab(commit_graph_data_slab, struct commit_graph_data); static struct commit_graph_data_slab commit_graph_data_slab = COMMIT_SLAB_INIT(1, commit_graph_data_slab); +static int get_configured_generation_version(struct repository *r) +{ + int version = 2; + repo_config_get_int(r, "commitgraph.generationversion", &version); + return version; +} + uint32_t commit_graph_position(const struct commit *c) { struct commit_graph_data *data = @@ -394,10 +401,13 @@ struct commit_graph *parse_commit_graph(struct repository *r, pair_chunk(cf, GRAPH_CHUNKID_DATA, &graph->chunk_commit_data); pair_chunk(cf, GRAPH_CHUNKID_EXTRAEDGES, &graph->chunk_extra_edges); pair_chunk(cf, GRAPH_CHUNKID_BASE, &graph->chunk_base_graphs); - pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA, - &graph->chunk_generation_data); - pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA_OVERFLOW, - &graph->chunk_generation_data_overflow); + + if (get_configured_generation_version(r) >= 2) { + pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA, + &graph->chunk_generation_data); + pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA_OVERFLOW, + &graph->chunk_generation_data_overflow); + } if (r->settings.commit_graph_read_changed_paths) { pair_chunk(cf, GRAPH_CHUNKID_BLOOMINDEXES, @@ -1771,8 +1781,6 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx) add_chunk(cf, GRAPH_CHUNKID_DATA, (hashsz + 16) * ctx->commits.nr, write_graph_chunk_data); - if (git_env_bool(GIT_TEST_COMMIT_GRAPH_NO_GDAT, 0)) - ctx->write_generation_data = 0; if (ctx->write_generation_data) add_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA, sizeof(uint32_t) * ctx->commits.nr, @@ -2179,7 +2187,7 @@ int write_commit_graph(struct object_directory *odb, ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0; ctx->opts = opts; ctx->total_bloom_filter_data_size = 0; - ctx->write_generation_data = 1; + ctx->write_generation_data = (get_configured_generation_version(r) == 2); ctx->num_generation_data_overflows = 0; bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY", |