Convert resolve_ref+xstrdup to new resolve_refdup function
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e4776bd936
commit
96ec7b1e70
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user