transport: use parse_oid_hex instead of a constant
Use parse_oid_hex to compute a pointer instead of using GIT_SHA1_HEXSZ. This simplifies the code and makes it independent of the hash length. 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
fbd0e37cde633221d5b3ca239f26cb7d005da5c8
1 file changed
+4
-3
transport.c
+4
-3
@@ -1346,15 +1346,16 @@ static void read_alternate_refs(const char *path,
1346
fh = xfdopen(cmd.out, "r");
1347
while (strbuf_getline_lf(&line, fh) != EOF) {
1348
struct object_id oid;
1349
+ const char *p;
1350
1350
- if (get_oid_hex(line.buf, &oid) ||
1351
- line.buf[GIT_SHA1_HEXSZ] != ' ') {
1351
+ if (parse_oid_hex(line.buf, &oid, &p) ||
1352
+ *p != ' ') {
1353
warning(_("invalid line while parsing alternate refs: %s"),
1354
line.buf);
1355
break;
1356
}
1357
1357
- cb(line.buf + GIT_SHA1_HEXSZ + 1, &oid, data);
1358
+ cb(p + 1, &oid, data);
1359
}
1360
1361
fclose(fh);