Skip to content

Commit 702110a

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c7ef8fe commit 702110a

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

Documentation/config/commitgraph.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
commitGraph.generationVersion::
2+
Specifies the type of generation number version to use when writing
3+
or reading the commit-graph file. If version 1 is specified, then
4+
the corrected commit dates will not be written or read. Defaults to
5+
2.
6+
17
commitGraph.maxNewFilters::
28
Specifies the default value for the `--max-new-filters` option of `git
39
commit-graph write` (c.f., linkgit:git-commit-graph[1]).

commit-graph.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ define_commit_slab(commit_graph_data_slab, struct commit_graph_data);
9696
static struct commit_graph_data_slab commit_graph_data_slab =
9797
COMMIT_SLAB_INIT(1, commit_graph_data_slab);
9898

99+
static int get_configured_generation_version(struct repository *r)
100+
{
101+
int version = 2;
102+
repo_config_get_int(r, "commitgraph.generationversion", &version);
103+
return version;
104+
}
105+
99106
uint32_t commit_graph_position(const struct commit *c)
100107
{
101108
struct commit_graph_data *data =
@@ -394,10 +401,13 @@ struct commit_graph *parse_commit_graph(struct repository *r,
394401
pair_chunk(cf, GRAPH_CHUNKID_DATA, &graph->chunk_commit_data);
395402
pair_chunk(cf, GRAPH_CHUNKID_EXTRAEDGES, &graph->chunk_extra_edges);
396403
pair_chunk(cf, GRAPH_CHUNKID_BASE, &graph->chunk_base_graphs);
397-
pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
398-
&graph->chunk_generation_data);
399-
pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA_OVERFLOW,
400-
&graph->chunk_generation_data_overflow);
404+
405+
if (get_configured_generation_version(r) >= 2) {
406+
pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
407+
&graph->chunk_generation_data);
408+
pair_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA_OVERFLOW,
409+
&graph->chunk_generation_data_overflow);
410+
}
401411

402412
if (r->settings.commit_graph_read_changed_paths) {
403413
pair_chunk(cf, GRAPH_CHUNKID_BLOOMINDEXES,
@@ -1771,8 +1781,6 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
17711781
add_chunk(cf, GRAPH_CHUNKID_DATA, (hashsz + 16) * ctx->commits.nr,
17721782
write_graph_chunk_data);
17731783

1774-
if (git_env_bool(GIT_TEST_COMMIT_GRAPH_NO_GDAT, 0))
1775-
ctx->write_generation_data = 0;
17761784
if (ctx->write_generation_data)
17771785
add_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
17781786
sizeof(uint32_t) * ctx->commits.nr,
@@ -2179,7 +2187,7 @@ int write_commit_graph(struct object_directory *odb,
21792187
ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
21802188
ctx->opts = opts;
21812189
ctx->total_bloom_filter_data_size = 0;
2182-
ctx->write_generation_data = 1;
2190+
ctx->write_generation_data = (get_configured_generation_version(r) == 2);
21832191
ctx->num_generation_data_overflows = 0;
21842192

21852193
bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",

commit-graph.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "oidset.h"
77

88
#define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH"
9-
#define GIT_TEST_COMMIT_GRAPH_NO_GDAT "GIT_TEST_COMMIT_GRAPH_NO_GDAT"
109
#define GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE "GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE"
1110
#define GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS "GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS"
1211

t/README

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ GIT_TEST_COMMIT_GRAPH=<boolean>, when true, forces the commit-graph to
393393
be written after every 'git commit' command, and overrides the
394394
'core.commitGraph' setting to true.
395395

396-
GIT_TEST_COMMIT_GRAPH_NO_GDAT=<boolean>, when true, forces the
397-
commit-graph to be written without generation data chunk.
398-
399396
GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=<boolean>, when true, forces
400397
commit-graph write to compute and write changed path Bloom filters for
401398
every 'git commit-graph write', as if the `--changed-paths` option was

t/t5318-commit-graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ test_expect_success 'warn on improper hash version' '
454454

455455
test_expect_success 'git commit-graph verify' '
456456
cd "$TRASH_DIRECTORY/full" &&
457-
git rev-parse commits/8 | GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --stdin-commits &&
457+
git rev-parse commits/8 | git -c commitGraph.generationVersion=1 commit-graph write --stdin-commits &&
458458
git commit-graph verify >output &&
459459
graph_read_expect 9 extra_edges
460460
'

t/t5324-split-commit-graph.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,15 @@ test_expect_success 'setup repo for mixed generation commit-graph-chain' '
489489
test_commit $i &&
490490
git branch commits/$i || return 1
491491
done &&
492-
git commit-graph write --reachable --split &&
492+
git -c commitGraph.generationVersion=2 commit-graph write --reachable --split &&
493493
graph_read_expect $NUM_FIRST_LAYER_COMMITS &&
494494
test_line_count = 1 $graphdir/commit-graph-chain &&
495495
for i in $(test_seq $SECOND_LAYER_SEQUENCE_START $SECOND_LAYER_SEQUENCE_END)
496496
do
497497
test_commit $i &&
498498
git branch commits/$i || return 1
499499
done &&
500-
GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --reachable --split=no-merge &&
500+
git -c commitGraph.generationVersion=1 commit-graph write --reachable --split=no-merge &&
501501
test_line_count = 2 $graphdir/commit-graph-chain &&
502502
test-tool read-graph >output &&
503503
cat >expect <<-EOF &&

t/t6600-test-reach.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test_expect_success 'setup' '
5555
git show-ref -s commit-5-5 | git commit-graph write --stdin-commits &&
5656
mv .git/objects/info/commit-graph commit-graph-half &&
5757
chmod u+w commit-graph-half &&
58-
GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --reachable &&
58+
git -c commitGraph.generationVersion=1 commit-graph write --reachable &&
5959
mv .git/objects/info/commit-graph commit-graph-no-gdat &&
6060
chmod u+w commit-graph-no-gdat &&
6161
git config core.commitGraph true

0 commit comments

Comments
 (0)