summaryrefslogtreecommitdiff
path: root/builtin-update-index.c
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2006-08-17 11:54:57 -0700
committerJunio C Hamano <junkio@cox.net>2006-08-17 14:23:53 -0700
commita89fccd28197fa179828c8596791ff16e2268d20 (patch)
tree4a6c2b256a986fc221c0e1d5fa7d910f3b31eee8 /builtin-update-index.c
parentd4baf9eaf47ea1ba204f1ab5ecd22326913dd081 (diff)
downloadgit-a89fccd28197fa179828c8596791ff16e2268d20.tar.gz
Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.
Introduces global inline: hashcmp(const unsigned char *sha1, const unsigned char *sha2) Uses memcmp for comparison and returns the result based on the length of the hash name (a future runtime decision). Acked-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-update-index.c')
-rw-r--r--builtin-update-index.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 9f0cf28ba2..5dd91af180 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -378,7 +378,7 @@ static int unresolve_one(const char *path)
ret = -1;
goto free_return;
}
- if (!memcmp(ce_2->sha1, ce_3->sha1, 20) &&
+ if (!hashcmp(ce_2->sha1, ce_3->sha1) &&
ce_2->ce_mode == ce_3->ce_mode) {
fprintf(stderr, "%s: identical in both, skipping.\n",
path);
@@ -460,7 +460,7 @@ static int do_reupdate(int ac, const char **av,
old = read_one_ent(NULL, head_sha1,
ce->name, ce_namelen(ce), 0);
if (old && ce->ce_mode == old->ce_mode &&
- !memcmp(ce->sha1, old->sha1, 20)) {
+ !hashcmp(ce->sha1, old->sha1)) {
free(old);
continue; /* unchanged */
}