Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/unpack-objects: switch uses of SHA-1 to the_hash_algo
author
brian m. carlson
<sandals@crustytoothpaste.net>
Thu, 1 Feb 2018 02:18:40 +0000
(
02:18
+0000)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 2 Feb 2018 19:28:41 +0000
(11:28 -0800)
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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/unpack-objects.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
454253f
)
diff --git
a/builtin/unpack-objects.c
b/builtin/unpack-objects.c
index 62ea264c46783374d0f1968c19ea7581498a1f87..813ca319790665c0344a86e7ebd8cfe609ce307e 100644
(file)
--- a/
builtin/unpack-objects.c
+++ b/
builtin/unpack-objects.c
@@
-21,7
+21,7
@@
static unsigned char buffer[4096];
static unsigned int offset, len;
static off_t consumed_bytes;
static off_t max_input_size;
static unsigned int offset, len;
static off_t consumed_bytes;
static off_t max_input_size;
-static git_
SHA_CTX
ctx;
+static git_
hash_ctx
ctx;
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
/*
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
/*
@@
-62,7
+62,7
@@
static void *fill(int min)
if (min > sizeof(buffer))
die("cannot fill %d bytes", min);
if (offset) {
if (min > sizeof(buffer))
die("cannot fill %d bytes", min);
if (offset) {
-
git_SHA1_Update
(&ctx, buffer, offset);
+
the_hash_algo->update_fn
(&ctx, buffer, offset);
memmove(buffer, buffer + offset, len);
offset = 0;
}
memmove(buffer, buffer + offset, len);
offset = 0;
}
@@
-345,8
+345,8
@@
static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
struct object_id base_oid;
if (type == OBJ_REF_DELTA) {
struct object_id base_oid;
if (type == OBJ_REF_DELTA) {
- hashcpy(base_oid.hash, fill(
GIT_SHA1_RAWSZ
));
- use(
GIT_SHA1_RAWSZ
);
+ hashcpy(base_oid.hash, fill(
the_hash_algo->rawsz
));
+ use(
the_hash_algo->rawsz
);
delta_data = get_data(delta_size);
if (dry_run || !delta_data) {
free(delta_data);
delta_data = get_data(delta_size);
if (dry_run || !delta_data) {
free(delta_data);
@@
-564,15
+564,15
@@
int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
/* We don't take any non-flag arguments now.. Maybe some day */
usage(unpack_usage);
}
/* We don't take any non-flag arguments now.. Maybe some day */
usage(unpack_usage);
}
-
git_SHA1_Init
(&ctx);
+
the_hash_algo->init_fn
(&ctx);
unpack_all();
unpack_all();
-
git_SHA1_Update
(&ctx, buffer, offset);
-
git_SHA1_Final
(oid.hash, &ctx);
+
the_hash_algo->update_fn
(&ctx, buffer, offset);
+
the_hash_algo->final_fn
(oid.hash, &ctx);
if (strict)
write_rest();
if (strict)
write_rest();
- if (hashcmp(fill(
GIT_SHA1_RAWSZ
), oid.hash))
+ if (hashcmp(fill(
the_hash_algo->rawsz
), oid.hash))
die("final sha1 did not match");
die("final sha1 did not match");
- use(
GIT_SHA1_RAWSZ
);
+ use(
the_hash_algo->rawsz
);
/* Write the last part of the buffer to stdout */
while (len) {
/* Write the last part of the buffer to stdout */
while (len) {