delete_branches(): use resolve_refdup()
The return value of resolve_ref_unsafe() is not guaranteed to stay around as long as we need it, so use resolve_refdup() instead. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>maint
parent
5a563d4ad1
commit
8bb0455367
|
@ -212,7 +212,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||||
die(_("Couldn't look up commit object for HEAD"));
|
die(_("Couldn't look up commit object for HEAD"));
|
||||||
}
|
}
|
||||||
for (i = 0; i < argc; i++, strbuf_release(&bname)) {
|
for (i = 0; i < argc; i++, strbuf_release(&bname)) {
|
||||||
const char *target;
|
char *target = NULL;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
strbuf_branchname(&bname, argv[i]);
|
strbuf_branchname(&bname, argv[i]);
|
||||||
|
@ -231,7 +231,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target = resolve_ref_unsafe(name,
|
target = resolve_refdup(name,
|
||||||
RESOLVE_REF_READING
|
RESOLVE_REF_READING
|
||||||
| RESOLVE_REF_NO_RECURSE
|
| RESOLVE_REF_NO_RECURSE
|
||||||
| RESOLVE_REF_ALLOW_BAD_NAME,
|
| RESOLVE_REF_ALLOW_BAD_NAME,
|
||||||
|
@ -248,7 +248,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||||
check_branch_commit(bname.buf, name, sha1, head_rev, kinds,
|
check_branch_commit(bname.buf, name, sha1, head_rev, kinds,
|
||||||
force)) {
|
force)) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
continue;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1,
|
if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1,
|
||||||
|
@ -258,7 +258,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||||
: _("Error deleting branch '%s'"),
|
: _("Error deleting branch '%s'"),
|
||||||
bname.buf);
|
bname.buf);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
continue;
|
goto next;
|
||||||
}
|
}
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
printf(remote_branch
|
printf(remote_branch
|
||||||
|
@ -270,6 +270,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
||||||
: find_unique_abbrev(sha1, DEFAULT_ABBREV));
|
: find_unique_abbrev(sha1, DEFAULT_ABBREV));
|
||||||
}
|
}
|
||||||
delete_branch_config(bname.buf);
|
delete_branch_config(bname.buf);
|
||||||
|
|
||||||
|
next:
|
||||||
|
free(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
Loading…
Reference in New Issue