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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 1, 2018 at 02:18 UTC f87e8137187e0c9abe39b15cb4b6f5cdc76a70b0
1 file changed +6 -6
bulk-checkin.c
+6 -6
@@ -93,7 +93,7 @@ static int already_written(struct bulk_checkin_state *state, unsigned char sha1[
93 * with a new pack.
94 */
95 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,
97 int fd, size_t size, enum object_type type,
98 const char *path, unsigned flags)
99 {
@@ -127,7 +127,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
127 if (rsize < hsize)
128 hsize = rsize;
129 if (hsize)
130 - git_SHA1_Update(ctx, ibuf, hsize);
130 + the_hash_algo->update_fn(ctx, ibuf, hsize);
131 *already_hashed_to = offset;
132 }
133 s.next_in = ibuf;
@@ -192,7 +192,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
192 unsigned flags)
193 {
194 off_t seekback, already_hashed_to;
195 - git_SHA_CTX ctx;
195 + git_hash_ctx ctx;
196 unsigned char obuf[16384];
197 unsigned header_len;
198 struct hashfile_checkpoint checkpoint;
@@ -204,8 +204,8 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
204
205 header_len = xsnprintf((char *)obuf, sizeof(obuf), "%s %" PRIuMAX,
206 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);
209
210 /* Note: idx is non-NULL when we are writing */
211 if ((flags & HASH_WRITE_OBJECT) != 0)
@@ -236,7 +236,7 @@ static int deflate_to_pack(struct bulk_checkin_state *state,
236 if (lseek(fd, seekback, SEEK_SET) == (off_t) -1)
237 return error("cannot seek back");
238 }
239 - git_SHA1_Final(result_sha1, &ctx);
239 + the_hash_algo->final_fn(result_sha1, &ctx);
240 if (!idx)
241 return 0;
242