summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-06-20 07:40:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-20 16:23:53 (GMT)
commit6d79e5ecb342586466e0321487f08f17cbccb2bb (patch)
treedaa6ac9a5e30c8d5f6a5a32433a469836891f5fe
parenta6a95cd1b46e48e5fe06bdbb0839a67ebeef4682 (diff)
downloadgit-6d79e5ecb342586466e0321487f08f17cbccb2bb.zip
git-6d79e5ecb342586466e0321487f08f17cbccb2bb.tar.gz
git-6d79e5ecb342586466e0321487f08f17cbccb2bb.tar.bz2
describe: fix accidental oid/hash type-punning
The find_commit_name() function passes an object_id.hash as the key of a hashmap. That ends up in commit_name_neq(), which then feeds it to oideq(). Which means we should actually be the whole "struct object_id". It works anyway because pointers to the two are interchangeable. And because we're going through a layer of void pointers, the compiler doesn't notice the type mismatch. But it's worth cleaning up (especially since once we switch away from sha1hash() on the same line, accessing the hash member will look doubly out of place). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/describe.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 1409ced..0a5cde0 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -76,7 +76,7 @@ static int commit_name_neq(const void *unused_cmp_data,
static inline struct commit_name *find_commit_name(const struct object_id *peeled)
{
- return hashmap_get_from_hash(&names, sha1hash(peeled->hash), peeled->hash);
+ return hashmap_get_from_hash(&names, sha1hash(peeled->hash), peeled);
}
static int replace_name(struct commit_name *e,