connect.c: allow ssh://user@[2001:db8::1]/repo.git
[gitweb.git] / builtin / fmt-merge-msg.c
index ef8b254ef218249f7f1b0f28db7ea21110851917..37177c6c2928b926cf55cacfdcfcf033bf012e80 100644 (file)
@@ -100,7 +100,8 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
 {
        int i, len = strlen(line);
        struct origin_data *origin_data;
-       char *src, *origin;
+       char *src;
+       const char *origin;
        struct src_data *src_data;
        struct string_list_item *item;
        int pulling_head = 0;
@@ -164,8 +165,7 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
                origin = line;
                string_list_append(&src_data->tag, origin + 4);
                src_data->head_status |= 2;
-       } else if (starts_with(line, "remote-tracking branch ")) {
-               origin = line + strlen("remote-tracking branch ");
+       } else if (skip_prefix(line, "remote-tracking branch ", &origin)) {
                string_list_append(&src_data->r_branch, origin);
                src_data->head_status |= 2;
        } else {
@@ -178,11 +178,8 @@ static int handle_line(char *line, struct merge_parents *merge_parents)
                int len = strlen(origin);
                if (origin[0] == '\'' && origin[len - 1] == '\'')
                        origin = xmemdupz(origin + 1, len - 2);
-       } else {
-               char *new_origin = xmalloc(strlen(origin) + strlen(src) + 5);
-               sprintf(new_origin, "%s of %s", origin, src);
-               origin = new_origin;
-       }
+       } else
+               origin = xstrfmt("%s of %s", origin, src);
        if (strcmp(".", src))
                origin_data->is_local_branch = 0;
        string_list_append(&origins, origin)->util = origin_data;
@@ -300,8 +297,8 @@ static void credit_people(struct strbuf *out,
        if (!them->nr ||
            (them->nr == 1 &&
             me &&
-            (me = skip_prefix(me, them->items->string)) != NULL &&
-            skip_prefix(me, " <")))
+            skip_prefix(me, them->items->string, &me) &&
+            starts_with(me, " <")))
                return;
        strbuf_addf(out, "\n%c %s ", comment_line_char, label);
        add_people_count(out, them);
@@ -605,7 +602,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
 
        /* get current branch */
        current_branch = current_branch_to_free =
-               resolve_refdup("HEAD", head_sha1, 1, NULL);
+               resolve_refdup("HEAD", RESOLVE_REF_READING, head_sha1, NULL);
        if (!current_branch)
                die("No current branch");
        if (starts_with(current_branch, "refs/heads/"))