rerere: tighten rr-cache dirname check
authorJeff King <peff@peff.net>
Thu, 28 Jan 2021 06:16:50 +0000 (01:16 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Jan 2021 19:25:43 +0000 (11:25 -0800)
commit098c173f2bd6260faa8f21a3dc375e23bda6b554
tree50f10091943ba5f216565d2b3dcb5535668ce6d8
parent2bc1a87e42cc07408a1e7442a3315d1e27b8737f
rerere: tighten rr-cache dirname check

We check only that get_sha1_hex() doesn't complain, which means we'd
match an all-hex name with trailing cruft after it. This probably
doesn't matter much in practice, since there shouldn't be anything else
in the rr-cache directory, but it could possibly cause us to mix up sha1
and sha256 entries (which also shouldn't be intermingled, but could be
leftovers from a repository conversion).

Note that "get_sha1_hex()" is a confusing historical name. It is
actually using the_hash_algo, so it would be sha256 in a sha256 repo.
We'll switch to using parse_oid_hex(), because that conveniently
advances our pointer. But it also gets rid of the sha1 name. Arguably
it's a little funny to use "object_id" here for something that isn't
actually naming an object, but it's unlikely to be a problem (and is
contained in a single function).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rerere.c