@@ -265,7 +265,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
265265
266266 graph_size = xsize_t (st -> st_size );
267267
268- if (graph_size < graph_min_size (the_hash_algo )) {
268+ if (graph_size < graph_min_size (r -> hash_algo )) {
269269 close (fd );
270270 error (_ ("commit-graph file is too small" ));
271271 return NULL ;
@@ -320,7 +320,7 @@ static int graph_read_commit_data(const unsigned char *chunk_start,
320320 size_t chunk_size , void * data )
321321{
322322 struct commit_graph * g = data ;
323- if (chunk_size / graph_data_width (the_hash_algo ) != g -> num_commits )
323+ if (chunk_size / graph_data_width (g -> hash_algo ) != g -> num_commits )
324324 return error (_ ("commit-graph commit data chunk is wrong size" ));
325325 g -> chunk_commit_data = chunk_start ;
326326 return 0 ;
@@ -621,7 +621,8 @@ static int add_graph_to_chain(struct commit_graph *g,
621621}
622622
623623int open_commit_graph_chain (const char * chain_file ,
624- int * fd , struct stat * st )
624+ int * fd , struct stat * st ,
625+ const struct git_hash_algo * hash_algo )
625626{
626627 * fd = git_open (chain_file );
627628 if (* fd < 0 )
@@ -630,7 +631,7 @@ int open_commit_graph_chain(const char *chain_file,
630631 close (* fd );
631632 return 0 ;
632633 }
633- if (st -> st_size < the_hash_algo -> hexsz ) {
634+ if (st -> st_size < hash_algo -> hexsz ) {
634635 close (* fd );
635636 if (!st -> st_size ) {
636637 /* treat empty files the same as missing */
@@ -654,7 +655,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
654655 int i = 0 , valid = 1 , count ;
655656 FILE * fp = xfdopen (fd , "r" );
656657
657- count = st -> st_size / (the_hash_algo -> hexsz + 1 );
658+ count = st -> st_size / (r -> hash_algo -> hexsz + 1 );
658659 CALLOC_ARRAY (oids , count );
659660
660661 odb_prepare_alternates (r -> objects );
@@ -716,7 +717,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
716717 int fd ;
717718 struct commit_graph * g = NULL ;
718719
719- if (open_commit_graph_chain (chain_file , & fd , & st )) {
720+ if (open_commit_graph_chain (chain_file , & fd , & st , r -> hash_algo )) {
720721 int incomplete ;
721722 /* ownership of fd is taken over by load function */
722723 g = load_commit_graph_chain_fd_st (r , fd , & st , & incomplete );
@@ -908,7 +909,7 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g,
908909 die (_ ("invalid commit position. commit-graph is likely corrupt" ));
909910
910911 lex_index = pos - g -> num_commits_in_base ;
911- commit_data = g -> chunk_commit_data + st_mult (graph_data_width (the_hash_algo ), lex_index );
912+ commit_data = g -> chunk_commit_data + st_mult (graph_data_width (g -> hash_algo ), lex_index );
912913
913914 graph_data = commit_graph_data_at (item );
914915 graph_data -> graph_pos = pos ;
@@ -1112,7 +1113,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
11121113 g = g -> base_graph ;
11131114
11141115 commit_data = g -> chunk_commit_data +
1115- st_mult (graph_data_width (the_hash_algo ),
1116+ st_mult (graph_data_width (g -> hash_algo ),
11161117 graph_pos - g -> num_commits_in_base );
11171118
11181119 oidread (& oid , commit_data , the_repository -> hash_algo );
@@ -1221,7 +1222,7 @@ static int write_graph_chunk_oids(struct hashfile *f,
12211222 int count ;
12221223 for (count = 0 ; count < ctx -> commits .nr ; count ++ , list ++ ) {
12231224 display_progress (ctx -> progress , ++ ctx -> progress_cnt );
1224- hashwrite (f , (* list )-> object .oid .hash , the_hash_algo -> rawsz );
1225+ hashwrite (f , (* list )-> object .oid .hash , f -> algop -> rawsz );
12251226 }
12261227
12271228 return 0 ;
@@ -1252,7 +1253,7 @@ static int write_graph_chunk_data(struct hashfile *f,
12521253 die (_ ("unable to parse commit %s" ),
12531254 oid_to_hex (& (* list )-> object .oid ));
12541255 tree = get_commit_tree_oid (* list );
1255- hashwrite (f , tree -> hash , the_hash_algo -> rawsz );
1256+ hashwrite (f , tree -> hash , ctx -> r -> hash_algo -> rawsz );
12561257
12571258 parent = (* list )-> parents ;
12581259
@@ -2035,7 +2036,7 @@ static int write_graph_chunk_base_1(struct hashfile *f,
20352036 return 0 ;
20362037
20372038 num = write_graph_chunk_base_1 (f , g -> base_graph );
2038- hashwrite (f , g -> oid .hash , the_hash_algo -> rawsz );
2039+ hashwrite (f , g -> oid .hash , g -> hash_algo -> rawsz );
20392040 return num + 1 ;
20402041}
20412042
@@ -2059,7 +2060,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
20592060 struct hashfile * f ;
20602061 struct tempfile * graph_layer ; /* when ctx->split is non-zero */
20612062 struct lock_file lk = LOCK_INIT ;
2062- const unsigned hashsz = the_hash_algo -> rawsz ;
2063+ const unsigned hashsz = ctx -> r -> hash_algo -> rawsz ;
20632064 struct strbuf progress_title = STRBUF_INIT ;
20642065 struct chunkfile * cf ;
20652066 unsigned char file_hash [GIT_MAX_RAWSZ ];
@@ -2147,7 +2148,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
21472148 hashwrite_be32 (f , GRAPH_SIGNATURE );
21482149
21492150 hashwrite_u8 (f , GRAPH_VERSION );
2150- hashwrite_u8 (f , oid_version (the_hash_algo ));
2151+ hashwrite_u8 (f , oid_version (ctx -> r -> hash_algo ));
21512152 hashwrite_u8 (f , get_num_chunks (cf ));
21522153 hashwrite_u8 (f , ctx -> num_commit_graphs_after - 1 );
21532154
0 commit comments