builtin/am: make hash size independent
Instead of using GIT_SHA1_HEXSZ, switch to using the_hash_algo and parse_oid_hex to parse the lines involved in rebasing notes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 19, 2019 at 00:05 UTC
24dd363ed586f5edbdea96689d4e0e40a7d3f7fa
1 file changed
+5
-4
builtin/am.c
+5
-4
@@ -486,23 +486,24 @@ static int copy_notes_for_rebase(const struct am_state *state)
486
487
while (!strbuf_getline_lf(&sb, fp)) {
488
struct object_id from_obj, to_obj;
489
+ const char *p;
490
490
- if (sb.len != GIT_SHA1_HEXSZ * 2 + 1) {
491
+ if (sb.len != the_hash_algo->hexsz * 2 + 1) {
492
ret = error(invalid_line, sb.buf);
493
goto finish;
494
}
495
495
- if (get_oid_hex(sb.buf, &from_obj)) {
496
+ if (parse_oid_hex(sb.buf, &from_obj, &p)) {
497
ret = error(invalid_line, sb.buf);
498
goto finish;
499
}
500
500
- if (sb.buf[GIT_SHA1_HEXSZ] != ' ') {
501
+ if (*p != ' ') {
502
ret = error(invalid_line, sb.buf);
503
goto finish;
504
}
505
505
- if (get_oid_hex(sb.buf + GIT_SHA1_HEXSZ + 1, &to_obj)) {
506
+ if (get_oid_hex(p + 1, &to_obj)) {
507
ret = error(invalid_line, sb.buf);
508
goto finish;
509
}