builtin/fetch-pack: remove constants with parse_oid_hex

Instead of using GIT_SHA1_HEXSZ, use parse_oid_hex to compute a pointer and use that in comparisons. This is both simpler to read and works independent of the hash length. Update references to SHA-1 in the same function to refer to object IDs instead. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Oct 15, 2018 at 00:01 UTC 7b5e614e2acc2f4e6b2f1ea4eb93dd430d350abd
1 file changed +7 -6
builtin/fetch-pack.c
+7 -6
@@ -16,13 +16,14 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
16 {
17 struct ref *ref;
18 struct object_id oid;
19 + const char *p;
20
20 - if (!get_oid_hex(name, &oid)) {
21 - if (name[GIT_SHA1_HEXSZ] == ' ') {
22 - /* <sha1> <ref>, find refname */
23 - name += GIT_SHA1_HEXSZ + 1;
24 - } else if (name[GIT_SHA1_HEXSZ] == '\0') {
25 - ; /* <sha1>, leave sha1 as name */
21 + if (!parse_oid_hex(name, &oid, &p)) {
22 + if (*p == ' ') {
23 + /* <oid> <ref>, find refname */
24 + name = p + 1;
25 + } else if (*p == '\0') {
26 + ; /* <oid>, leave oid as name */
27 } else {
28 /* <ref>, clear cruft from oid */
29 oidclr(&oid);