Skip to content

Commit d20fa3c

Browse files
committed
Merge branch 'ds/commit-graph-generation-config'
A new configuration variable has been introduced to allow choosing which version of the generation number gets used in the commit-graph file. * ds/commit-graph-generation-config: commit-graph: use config to specify generation type commit-graph: create local repository pointer
2 parents 52182e3 + 702110a commit d20fa3c

File tree

7 files changed

+30
-19
lines changed

7 files changed

+30
-19
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: 20 additions & 11 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,
@@ -1839,8 +1849,6 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
18391849
add_chunk(cf, GRAPH_CHUNKID_DATA, (hashsz + 16) * ctx->commits.nr,
18401850
write_graph_chunk_data);
18411851

1842-
if (git_env_bool(GIT_TEST_COMMIT_GRAPH_NO_GDAT, 0))
1843-
ctx->write_generation_data = 0;
18441852
if (ctx->write_generation_data)
18451853
add_chunk(cf, GRAPH_CHUNKID_GENERATION_DATA,
18461854
sizeof(uint32_t) * ctx->commits.nr,
@@ -2223,30 +2231,31 @@ int write_commit_graph(struct object_directory *odb,
22232231
enum commit_graph_write_flags flags,
22242232
const struct commit_graph_opts *opts)
22252233
{
2234+
struct repository *r = the_repository;
22262235
struct write_commit_graph_context *ctx;
22272236
uint32_t i;
22282237
int res = 0;
22292238
int replace = 0;
22302239
struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
22312240
struct topo_level_slab topo_levels;
22322241

2233-
prepare_repo_settings(the_repository);
2234-
if (!the_repository->settings.core_commit_graph) {
2242+
prepare_repo_settings(r);
2243+
if (!r->settings.core_commit_graph) {
22352244
warning(_("attempting to write a commit-graph, but 'core.commitGraph' is disabled"));
22362245
return 0;
22372246
}
2238-
if (!commit_graph_compatible(the_repository))
2247+
if (!commit_graph_compatible(r))
22392248
return 0;
22402249

22412250
CALLOC_ARRAY(ctx, 1);
2242-
ctx->r = the_repository;
2251+
ctx->r = r;
22432252
ctx->odb = odb;
22442253
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
22452254
ctx->report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0;
22462255
ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
22472256
ctx->opts = opts;
22482257
ctx->total_bloom_filter_data_size = 0;
2249-
ctx->write_generation_data = 1;
2258+
ctx->write_generation_data = (get_configured_generation_version(r) == 2);
22502259
ctx->num_generation_data_overflows = 0;
22512260

22522261
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
@@ -387,9 +387,6 @@ GIT_TEST_COMMIT_GRAPH=<boolean>, when true, forces the commit-graph to
387387
be written after every 'git commit' command, and overrides the
388388
'core.commitGraph' setting to true.
389389

390-
GIT_TEST_COMMIT_GRAPH_NO_GDAT=<boolean>, when true, forces the
391-
commit-graph to be written without generation data chunk.
392-
393390
GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=<boolean>, when true, forces
394391
commit-graph write to compute and write changed path Bloom filters for
395392
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
@@ -475,7 +475,7 @@ test_expect_success 'lower layers have overflow chunk' '
475475

476476
test_expect_success 'git commit-graph verify' '
477477
cd "$TRASH_DIRECTORY/full" &&
478-
git rev-parse commits/8 | GIT_TEST_COMMIT_GRAPH_NO_GDAT=1 git commit-graph write --stdin-commits &&
478+
git rev-parse commits/8 | git -c commitGraph.generationVersion=1 commit-graph write --stdin-commits &&
479479
git commit-graph verify >output &&
480480
graph_read_expect 9 extra_edges
481481
'

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)