Merge branch 'en/rerere-multi-stage-1-fix' into maint
[gitweb.git] / builtin / fmt-merge-msg.c
index ff165c0fcd209f1bab596905a61bdfa6b491208a..f35ff1612bb563c819b611e82f8e3a7730d32461 100644 (file)
@@ -110,14 +110,15 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
        struct string_list_item *item;
        int pulling_head = 0;
        struct object_id oid;
+       const unsigned hexsz = the_hash_algo->hexsz;
 
-       if (len < GIT_SHA1_HEXSZ + 3 || line[GIT_SHA1_HEXSZ] != '\t')
+       if (len < hexsz + 3 || line[hexsz] != '\t')
                return 1;
 
-       if (starts_with(line + GIT_SHA1_HEXSZ + 1, "not-for-merge"))
+       if (starts_with(line + hexsz + 1, "not-for-merge"))
                return 0;
 
-       if (line[GIT_SHA1_HEXSZ + 1] != '\t')
+       if (line[hexsz + 1] != '\t')
                return 2;
 
        i = get_oid_hex(line, &oid);
@@ -132,7 +133,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
 
        if (line[len - 1] == '\n')
                line[len - 1] = 0;
-       line += GIT_SHA1_HEXSZ + 2;
+       line += hexsz + 2;
 
        /*
         * At this point, line points at the beginning of comment e.g.
@@ -346,7 +347,7 @@ static void shortlog(const char *name,
 
        branch = deref_tag(the_repository, parse_object(the_repository, oid),
                           oid_to_hex(oid),
-                          GIT_SHA1_HEXSZ);
+                          the_hash_algo->hexsz);
        if (!branch || branch->type != OBJ_COMMIT)
                return;
 
@@ -549,6 +550,7 @@ static void find_merge_parents(struct merge_parents *result,
                int len;
                char *p = in->buf + pos;
                char *newline = strchr(p, '\n');
+               const char *q;
                struct object_id oid;
                struct commit *parent;
                struct object *obj;
@@ -556,10 +558,9 @@ static void find_merge_parents(struct merge_parents *result,
                len = newline ? newline - p : strlen(p);
                pos += len + !!newline;
 
-               if (len < GIT_SHA1_HEXSZ + 3 ||
-                   get_oid_hex(p, &oid) ||
-                   p[GIT_SHA1_HEXSZ] != '\t' ||
-                   p[GIT_SHA1_HEXSZ + 1] != '\t')
+               if (parse_oid_hex(p, &oid, &q) ||
+                   q[0] != '\t' ||
+                   q[1] != '\t')
                        continue; /* skip not-for-merge */
                /*
                 * Do not use get_merge_parent() here; we do not have
@@ -627,7 +628,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
                i++;
                p[len] = 0;
                if (handle_line(p, &merge_parents))
-                       die ("Error in line %d: %.*s", i, len, p);
+                       die("error in line %d: %.*s", i, len, p);
        }
 
        if (opts->add_title && srcs.nr)