@@ -264,7 +264,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *r,
264
264
265
265
graph_size = xsize_t (st -> st_size );
266
266
267
- if (graph_size < graph_min_size (the_hash_algo )) {
267
+ if (graph_size < graph_min_size (r -> hash_algo )) {
268
268
close (fd );
269
269
error (_ ("commit-graph file is too small" ));
270
270
return NULL ;
@@ -319,7 +319,7 @@ static int graph_read_commit_data(const unsigned char *chunk_start,
319
319
size_t chunk_size , void * data )
320
320
{
321
321
struct commit_graph * g = data ;
322
- if (chunk_size / graph_data_width (the_hash_algo ) != g -> num_commits )
322
+ if (chunk_size / graph_data_width (g -> hash_algo ) != g -> num_commits )
323
323
return error (_ ("commit-graph commit data chunk is wrong size" ));
324
324
g -> chunk_commit_data = chunk_start ;
325
325
return 0 ;
@@ -620,7 +620,8 @@ static int add_graph_to_chain(struct commit_graph *g,
620
620
}
621
621
622
622
int open_commit_graph_chain (const char * chain_file ,
623
- int * fd , struct stat * st )
623
+ int * fd , struct stat * st ,
624
+ const struct git_hash_algo * hash_algo )
624
625
{
625
626
* fd = git_open (chain_file );
626
627
if (* fd < 0 )
@@ -629,7 +630,7 @@ int open_commit_graph_chain(const char *chain_file,
629
630
close (* fd );
630
631
return 0 ;
631
632
}
632
- if (st -> st_size < (ssize_t ) the_hash_algo -> hexsz ) {
633
+ if (st -> st_size < (ssize_t ) hash_algo -> hexsz ) {
633
634
close (* fd );
634
635
if (!st -> st_size ) {
635
636
/* treat empty files the same as missing */
@@ -654,7 +655,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r,
654
655
FILE * fp = xfdopen (fd , "r" );
655
656
size_t count ;
656
657
657
- count = st -> st_size / (the_hash_algo -> hexsz + 1 );
658
+ count = st -> st_size / (r -> hash_algo -> hexsz + 1 );
658
659
CALLOC_ARRAY (oids , count );
659
660
660
661
odb_prepare_alternates (r -> objects );
@@ -716,7 +717,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
716
717
int fd ;
717
718
struct commit_graph * g = NULL ;
718
719
719
- if (open_commit_graph_chain (chain_file , & fd , & st )) {
720
+ if (open_commit_graph_chain (chain_file , & fd , & st , r -> hash_algo )) {
720
721
int incomplete ;
721
722
/* ownership of fd is taken over by load function */
722
723
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,
908
909
die (_ ("invalid commit position. commit-graph is likely corrupt" ));
909
910
910
911
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 );
912
913
913
914
graph_data = commit_graph_data_at (item );
914
915
graph_data -> graph_pos = pos ;
@@ -1112,7 +1113,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
1112
1113
g = g -> base_graph ;
1113
1114
1114
1115
commit_data = g -> chunk_commit_data +
1115
- st_mult (graph_data_width (the_hash_algo ),
1116
+ st_mult (graph_data_width (g -> hash_algo ),
1116
1117
graph_pos - g -> num_commits_in_base );
1117
1118
1118
1119
oidread (& oid , commit_data , the_repository -> hash_algo );
@@ -1222,7 +1223,7 @@ static int write_graph_chunk_oids(struct hashfile *f,
1222
1223
1223
1224
for (count = 0 ; count < ctx -> commits .nr ; count ++ , list ++ ) {
1224
1225
display_progress (ctx -> progress , ++ ctx -> progress_cnt );
1225
- hashwrite (f , (* list )-> object .oid .hash , the_hash_algo -> rawsz );
1226
+ hashwrite (f , (* list )-> object .oid .hash , f -> algop -> rawsz );
1226
1227
}
1227
1228
1228
1229
return 0 ;
@@ -1253,7 +1254,7 @@ static int write_graph_chunk_data(struct hashfile *f,
1253
1254
die (_ ("unable to parse commit %s" ),
1254
1255
oid_to_hex (& (* list )-> object .oid ));
1255
1256
tree = get_commit_tree_oid (* list );
1256
- hashwrite (f , tree -> hash , the_hash_algo -> rawsz );
1257
+ hashwrite (f , tree -> hash , ctx -> r -> hash_algo -> rawsz );
1257
1258
1258
1259
parent = (* list )-> parents ;
1259
1260
@@ -2035,7 +2036,7 @@ static size_t write_graph_chunk_base_1(struct hashfile *f,
2035
2036
return 0 ;
2036
2037
2037
2038
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 );
2039
2040
return num + 1 ;
2040
2041
}
2041
2042
@@ -2059,7 +2060,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
2059
2060
struct hashfile * f ;
2060
2061
struct tempfile * graph_layer ; /* when ctx->split is non-zero */
2061
2062
struct lock_file lk = LOCK_INIT ;
2062
- const unsigned hashsz = the_hash_algo -> rawsz ;
2063
+ const unsigned hashsz = ctx -> r -> hash_algo -> rawsz ;
2063
2064
struct strbuf progress_title = STRBUF_INIT ;
2064
2065
struct chunkfile * cf ;
2065
2066
unsigned char file_hash [GIT_MAX_RAWSZ ];
@@ -2147,7 +2148,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
2147
2148
hashwrite_be32 (f , GRAPH_SIGNATURE );
2148
2149
2149
2150
hashwrite_u8 (f , GRAPH_VERSION );
2150
- hashwrite_u8 (f , oid_version (the_hash_algo ));
2151
+ hashwrite_u8 (f , oid_version (ctx -> r -> hash_algo ));
2151
2152
hashwrite_u8 (f , get_num_chunks (cf ));
2152
2153
hashwrite_u8 (f , ctx -> num_commit_graphs_after - 1 );
2153
2154
0 commit comments