Skip to content

Commit 3206b6b

Browse files
bk2204gitster
authored andcommitted
builtin/unpack-objects: switch uses of SHA-1 to the_hash_algo
Switch various uses of explicit calls to SHA-1 into references to the_hash_algo to better abstract away the various uses of it. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 454253f commit 3206b6b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

builtin/unpack-objects.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static unsigned char buffer[4096];
2121
static unsigned int offset, len;
2222
static off_t consumed_bytes;
2323
static off_t max_input_size;
24-
static git_SHA_CTX ctx;
24+
static git_hash_ctx ctx;
2525
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
2626

2727
/*
@@ -62,7 +62,7 @@ static void *fill(int min)
6262
if (min > sizeof(buffer))
6363
die("cannot fill %d bytes", min);
6464
if (offset) {
65-
git_SHA1_Update(&ctx, buffer, offset);
65+
the_hash_algo->update_fn(&ctx, buffer, offset);
6666
memmove(buffer, buffer + offset, len);
6767
offset = 0;
6868
}
@@ -345,8 +345,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
345345
struct object_id base_oid;
346346

347347
if (type == OBJ_REF_DELTA) {
348-
hashcpy(base_oid.hash, fill(GIT_SHA1_RAWSZ));
349-
use(GIT_SHA1_RAWSZ);
348+
hashcpy(base_oid.hash, fill(the_hash_algo->rawsz));
349+
use(the_hash_algo->rawsz);
350350
delta_data = get_data(delta_size);
351351
if (dry_run || !delta_data) {
352352
free(delta_data);
@@ -564,15 +564,15 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
564564
/* We don't take any non-flag arguments now.. Maybe some day */
565565
usage(unpack_usage);
566566
}
567-
git_SHA1_Init(&ctx);
567+
the_hash_algo->init_fn(&ctx);
568568
unpack_all();
569-
git_SHA1_Update(&ctx, buffer, offset);
570-
git_SHA1_Final(oid.hash, &ctx);
569+
the_hash_algo->update_fn(&ctx, buffer, offset);
570+
the_hash_algo->final_fn(oid.hash, &ctx);
571571
if (strict)
572572
write_rest();
573-
if (hashcmp(fill(GIT_SHA1_RAWSZ), oid.hash))
573+
if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
574574
die("final sha1 did not match");
575-
use(GIT_SHA1_RAWSZ);
575+
use(the_hash_algo->rawsz);
576576

577577
/* Write the last part of the buffer to stdout */
578578
while (len) {

0 commit comments

Comments
 (0)