Skip to content

Commit f87e813

Browse files
bk2204gitster
authored andcommitted
bulk-checkin: abstract SHA-1 usage
Convert uses of the direct SHA-1 functions to use the_hash_algo instead. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d27350 commit f87e813

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bulk-checkin.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int already_written(struct bulk_checkin_state *state, unsigned char sha1[
9393
* with a new pack.
9494
*/
9595
static int stream_to_pack(struct bulk_checkin_state *state,
96-
git_SHA_CTX *ctx, off_t *already_hashed_to,
96+
git_hash_ctx *ctx, off_t *already_hashed_to,
9797
int fd, size_t size, enum object_type type,
9898
const char *path, unsigned flags)
9999
{
@@ -127,7 +127,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
127127
if (rsize < hsize)
128128
hsize = rsize;
129129
if (hsize)
130-
git_SHA1_Update(ctx, ibuf, hsize);
130+
the_hash_algo->update_fn(ctx, ibuf, hsize);
131131
*already_hashed_to = offset;
132132
}
133133
s.next_in = ibuf;
@@ -192,7 +192,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
192192
unsigned flags)
193193
{
194194
off_t seekback, already_hashed_to;
195-
git_SHA_CTX ctx;
195+
git_hash_ctx ctx;
196196
unsigned char obuf[16384];
197197
unsigned header_len;
198198
struct hashfile_checkpoint checkpoint;
@@ -204,8 +204,8 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
204204

205205
header_len = xsnprintf((char *)obuf, sizeof(obuf), "%s %" PRIuMAX,
206206
typename(type), (uintmax_t)size) + 1;
207-
git_SHA1_Init(&ctx);
208-
git_SHA1_Update(&ctx, obuf, header_len);
207+
the_hash_algo->init_fn(&ctx);
208+
the_hash_algo->update_fn(&ctx, obuf, header_len);
209209

210210
/* Note: idx is non-NULL when we are writing */
211211
if ((flags & HASH_WRITE_OBJECT) != 0)
@@ -236,7 +236,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
236236
if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
237237
return error("cannot seek back");
238238
}
239-
git_SHA1_Final(result_sha1, &ctx);
239+
the_hash_algo->final_fn(result_sha1, &ctx);
240240
if (!idx)
241241
return 0;
242242

0 commit comments

Comments
 (0)