]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/am: make hash size independent
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 19 Feb 2019 00:05:07 +0000 (00:05 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 02:57:38 +0000 (11:57 +0900)
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>
builtin/am.c

index 4fb107a9d1bdf36ff4c71d761abdda4d50d0e24b..5556a0651e6d45b10cecbc6ec4918f8505d8ae11 100644 (file)
@@ -486,23 +486,24 @@ static int copy_notes_for_rebase(const struct am_state *state)
 
        while (!strbuf_getline_lf(&sb, fp)) {
                struct object_id from_obj, to_obj;
+               const char *p;
 
-               if (sb.len != GIT_SHA1_HEXSZ * 2 + 1) {
+               if (sb.len != the_hash_algo->hexsz * 2 + 1) {
                        ret = error(invalid_line, sb.buf);
                        goto finish;
                }
 
-               if (get_oid_hex(sb.buf, &from_obj)) {
+               if (parse_oid_hex(sb.buf, &from_obj, &p)) {
                        ret = error(invalid_line, sb.buf);
                        goto finish;
                }
 
-               if (sb.buf[GIT_SHA1_HEXSZ] != ' ') {
+               if (*p != ' ') {
                        ret = error(invalid_line, sb.buf);
                        goto finish;
                }
 
-               if (get_oid_hex(sb.buf + GIT_SHA1_HEXSZ + 1, &to_obj)) {
+               if (get_oid_hex(p + 1, &to_obj)) {
                        ret = error(invalid_line, sb.buf);
                        goto finish;
                }