builtin/merge: switch to use the_hash_algo
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 16 Jul 2018 01:28:03 +0000 (01:28 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jul 2018 21:27:39 +0000 (14:27 -0700)
Switch uses of GIT_SHA1_HEXSZ to use the_hash_algo instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/merge.c
index 4a4c09496cfee08417c18cc010528464a3137488..916c9f05692e869085a12536c12e9e4d7d430439 100644 (file)
@@ -1034,6 +1034,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
        const char *filename;
        int fd, pos, npos;
        struct strbuf fetch_head_file = STRBUF_INIT;
        const char *filename;
        int fd, pos, npos;
        struct strbuf fetch_head_file = STRBUF_INIT;
+       const unsigned hexsz = the_hash_algo->hexsz;
 
        if (!merge_names)
                merge_names = &fetch_head_file;
 
        if (!merge_names)
                merge_names = &fetch_head_file;
@@ -1059,16 +1060,16 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
                else
                        npos = merge_names->len;
 
                else
                        npos = merge_names->len;
 
-               if (npos - pos < GIT_SHA1_HEXSZ + 2 ||
+               if (npos - pos < hexsz + 2 ||
                    get_oid_hex(merge_names->buf + pos, &oid))
                        commit = NULL; /* bad */
                    get_oid_hex(merge_names->buf + pos, &oid))
                        commit = NULL; /* bad */
-               else if (memcmp(merge_names->buf + pos + GIT_SHA1_HEXSZ, "\t\t", 2))
+               else if (memcmp(merge_names->buf + pos + hexsz, "\t\t", 2))
                        continue; /* not-for-merge */
                else {
                        continue; /* not-for-merge */
                else {
-                       char saved = merge_names->buf[pos + GIT_SHA1_HEXSZ];
-                       merge_names->buf[pos + GIT_SHA1_HEXSZ] = '\0';
+                       char saved = merge_names->buf[pos + hexsz];
+                       merge_names->buf[pos + hexsz] = '\0';
                        commit = get_merge_parent(merge_names->buf + pos);
                        commit = get_merge_parent(merge_names->buf + pos);
-                       merge_names->buf[pos + GIT_SHA1_HEXSZ] = saved;
+                       merge_names->buf[pos + hexsz] = saved;
                }
                if (!commit) {
                        if (ptr)
                }
                if (!commit) {
                        if (ptr)