Skip to content

Commit 7b5e614

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 58ce21b commit 7b5e614

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

builtin/fetch-pack.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
1616
{
1717
struct ref *ref;
1818
struct object_id oid;
19+
const char *p;
1920

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 */
2627
} else {
2728
/* <ref>, clear cruft from oid */
2829
oidclr(&oid);

0 commit comments

Comments
 (0)