@@ -1092,15 +1092,15 @@ static int store_object(
1092
1092
unsigned char hdr [96 ];
1093
1093
struct object_id oid ;
1094
1094
unsigned long hdrlen , deltalen ;
1095
- git_SHA_CTX c ;
1095
+ git_hash_ctx c ;
1096
1096
git_zstream s ;
1097
1097
1098
1098
hdrlen = xsnprintf ((char * )hdr , sizeof (hdr ), "%s %lu" ,
1099
1099
typename (type ), (unsigned long )dat -> len ) + 1 ;
1100
- git_SHA1_Init (& c );
1101
- git_SHA1_Update (& c , hdr , hdrlen );
1102
- git_SHA1_Update (& c , dat -> buf , dat -> len );
1103
- git_SHA1_Final (oid .hash , & c );
1100
+ the_hash_algo -> init_fn (& c );
1101
+ the_hash_algo -> update_fn (& c , hdr , hdrlen );
1102
+ the_hash_algo -> update_fn (& c , dat -> buf , dat -> len );
1103
+ the_hash_algo -> final_fn (oid .hash , & c );
1104
1104
if (oidout )
1105
1105
oidcpy (oidout , & oid );
1106
1106
@@ -1118,11 +1118,13 @@ static int store_object(
1118
1118
return 1 ;
1119
1119
}
1120
1120
1121
- if (last && last -> data .buf && last -> depth < max_depth && dat -> len > 20 ) {
1121
+ if (last && last -> data .buf && last -> depth < max_depth
1122
+ && dat -> len > the_hash_algo -> rawsz ) {
1123
+
1122
1124
delta_count_attempts_by_type [type ]++ ;
1123
1125
delta = diff_delta (last -> data .buf , last -> data .len ,
1124
1126
dat -> buf , dat -> len ,
1125
- & deltalen , dat -> len - 20 );
1127
+ & deltalen , dat -> len - the_hash_algo -> rawsz );
1126
1128
} else
1127
1129
delta = NULL ;
1128
1130
@@ -1231,7 +1233,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1231
1233
struct object_id oid ;
1232
1234
unsigned long hdrlen ;
1233
1235
off_t offset ;
1234
- git_SHA_CTX c ;
1236
+ git_hash_ctx c ;
1235
1237
git_zstream s ;
1236
1238
struct sha1file_checkpoint checkpoint ;
1237
1239
int status = Z_OK ;
@@ -1246,8 +1248,8 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1246
1248
1247
1249
hdrlen = xsnprintf ((char * )out_buf , out_sz , "blob %" PRIuMAX , len ) + 1 ;
1248
1250
1249
- git_SHA1_Init (& c );
1250
- git_SHA1_Update (& c , out_buf , hdrlen );
1251
+ the_hash_algo -> init_fn (& c );
1252
+ the_hash_algo -> update_fn (& c , out_buf , hdrlen );
1251
1253
1252
1254
crc32_begin (pack_file );
1253
1255
@@ -1265,7 +1267,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1265
1267
if (!n && feof (stdin ))
1266
1268
die ("EOF in data (%" PRIuMAX " bytes remaining)" , len );
1267
1269
1268
- git_SHA1_Update (& c , in_buf , n );
1270
+ the_hash_algo -> update_fn (& c , in_buf , n );
1269
1271
s .next_in = in_buf ;
1270
1272
s .avail_in = n ;
1271
1273
len -= n ;
@@ -1291,7 +1293,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1291
1293
}
1292
1294
}
1293
1295
git_deflate_end (& s );
1294
- git_SHA1_Final (oid .hash , & c );
1296
+ the_hash_algo -> final_fn (oid .hash , & c );
1295
1297
1296
1298
if (oidout )
1297
1299
oidcpy (oidout , & oid );
@@ -1350,25 +1352,25 @@ static void *gfi_unpack_entry(
1350
1352
{
1351
1353
enum object_type type ;
1352
1354
struct packed_git * p = all_packs [oe -> pack_id ];
1353
- if (p == pack_data && p -> pack_size < (pack_size + 20 )) {
1355
+ if (p == pack_data && p -> pack_size < (pack_size + the_hash_algo -> rawsz )) {
1354
1356
/* The object is stored in the packfile we are writing to
1355
1357
* and we have modified it since the last time we scanned
1356
1358
* back to read a previously written object. If an old
1357
- * window covered [p->pack_size, p->pack_size + 20 ) its
1359
+ * window covered [p->pack_size, p->pack_size + rawsz ) its
1358
1360
* data is stale and is not valid. Closing all windows
1359
1361
* and updating the packfile length ensures we can read
1360
1362
* the newly written data.
1361
1363
*/
1362
1364
close_pack_windows (p );
1363
1365
sha1flush (pack_file );
1364
1366
1365
- /* We have to offer 20 bytes additional on the end of
1367
+ /* We have to offer rawsz bytes additional on the end of
1366
1368
* the packfile as the core unpacker code assumes the
1367
1369
* footer is present at the file end and must promise
1368
- * at least 20 bytes within any window it maps. But
1370
+ * at least rawsz bytes within any window it maps. But
1369
1371
* we don't actually create the footer here.
1370
1372
*/
1371
- p -> pack_size = pack_size + 20 ;
1373
+ p -> pack_size = pack_size + the_hash_algo -> rawsz ;
1372
1374
}
1373
1375
return unpack_entry (p , oe -> idx .offset , & type , sizep );
1374
1376
}
@@ -2204,16 +2206,16 @@ static void construct_path_with_fanout(const char *hex_sha1,
2204
2206
unsigned char fanout , char * path )
2205
2207
{
2206
2208
unsigned int i = 0 , j = 0 ;
2207
- if (fanout >= 20 )
2209
+ if (fanout >= the_hash_algo -> rawsz )
2208
2210
die ("Too large fanout (%u)" , fanout );
2209
2211
while (fanout ) {
2210
2212
path [i ++ ] = hex_sha1 [j ++ ];
2211
2213
path [i ++ ] = hex_sha1 [j ++ ];
2212
2214
path [i ++ ] = '/' ;
2213
2215
fanout -- ;
2214
2216
}
2215
- memcpy (path + i , hex_sha1 + j , GIT_SHA1_HEXSZ - j );
2216
- path [i + GIT_SHA1_HEXSZ - j ] = '\0' ;
2217
+ memcpy (path + i , hex_sha1 + j , the_hash_algo -> hexsz - j );
2218
+ path [i + the_hash_algo -> hexsz - j ] = '\0' ;
2217
2219
}
2218
2220
2219
2221
static uintmax_t do_change_note_fanout (
0 commit comments