Code

Merge branch 'bw/maint-t8006-sed-incomplete-line'
[git.git] / builtin / fmt-merge-msg.c
index bdfa0ea05d99089937b9e753cf85a8489a5e27cb..c81a7fef2680620d521e118d60e8c59893d59234 100644 (file)
@@ -372,14 +372,15 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
        int i = 0, pos = 0;
        unsigned char head_sha1[20];
        const char *current_branch;
+       void *current_branch_to_free;
 
        /* get current branch */
-       current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
+       current_branch = current_branch_to_free =
+               resolve_refdup("HEAD", head_sha1, 1, NULL);
        if (!current_branch)
                die("No current branch");
        if (!prefixcmp(current_branch, "refs/heads/"))
                current_branch += 11;
-       current_branch = xstrdup(current_branch);
 
        /* get a line */
        while (pos < in->len) {
@@ -421,7 +422,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
        }
 
        strbuf_complete_line(out);
-       free((char *)current_branch);
+       free(current_branch_to_free);
        return 0;
 }