summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-08-28 21:22:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-29 18:32:49 (GMT)
commit67947c34ae8f666e72b9406a38984fe8386f5e50 (patch)
treec9ae21d6995cf9011777cb9d336bfa14f4587fc5 /builtin
parent9001dc2a7493f1366a183c3a9175f608769321d5 (diff)
downloadgit-67947c34ae8f666e72b9406a38984fe8386f5e50.zip
git-67947c34ae8f666e72b9406a38984fe8386f5e50.tar.gz
git-67947c34ae8f666e72b9406a38984fe8386f5e50.tar.bz2
convert "hashcmp() != 0" to "!hasheq()"
This rounds out the previous three patches, covering the inequality logic for the "hash" variant of the functions. As with the previous three, the accompanying code changes are the mechanical result of applying the coccinelle patch; see those patches for more discussion. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/index-pack.c4
-rw-r--r--builtin/show-branch.c2
-rw-r--r--builtin/unpack-objects.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index edcb0a3..2004e25 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1166,7 +1166,7 @@ static void parse_pack_objects(unsigned char *hash)
/* Check pack integrity */
flush();
the_hash_algo->final_fn(hash, &input_ctx);
- if (hashcmp(fill(the_hash_algo->rawsz), hash))
+ if (!hasheq(fill(the_hash_algo->rawsz), hash))
die(_("pack is corrupted (SHA1 mismatch)"));
use(the_hash_algo->rawsz);
@@ -1280,7 +1280,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha
fixup_pack_header_footer(output_fd, pack_hash,
curr_pack, nr_objects,
read_hash, consumed_bytes-the_hash_algo->rawsz);
- if (hashcmp(read_hash, tail_hash) != 0)
+ if (!hasheq(read_hash, tail_hash))
die(_("Unexpected tail checksum for %s "
"(disk corruption?)"), curr_pack);
}
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 5f94328..65f4a4c 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -485,7 +485,7 @@ static void snarf_refs(int head, int remotes)
static int rev_is_head(const char *head, const char *name,
unsigned char *head_sha1, unsigned char *sha1)
{
- if (!head || (head_sha1 && sha1 && hashcmp(head_sha1, sha1)))
+ if (!head || (head_sha1 && sha1 && !hasheq(head_sha1, sha1)))
return 0;
skip_prefix(head, "refs/heads/", &head);
if (!skip_prefix(name, "refs/heads/", &name))
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index ad438f5..8047880 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -579,7 +579,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
if (fsck_finish(&fsck_options))
die(_("fsck error in pack objects"));
}
- if (hashcmp(fill(the_hash_algo->rawsz), oid.hash))
+ if (!hasheq(fill(the_hash_algo->rawsz), oid.hash))
die("final sha1 did not match");
use(the_hash_algo->rawsz);