@@ -96,6 +96,13 @@ define_commit_slab(commit_graph_data_slab, struct commit_graph_data);
9696static 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+
99106uint32_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" ,
0 commit comments