Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
delete_branches(): use resolve_refdup()
author
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 25 Apr 2016 08:42:19 +0000
(10:42 +0200)
committer
Michael Haggerty
<mhagger@alum.mit.edu>
Mon, 13 Jun 2016 09:23:49 +0000
(11:23 +0200)
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>
builtin/branch.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5a563d4
)
diff --git
a/builtin/branch.c
b/builtin/branch.c
index 0adba629d2ae35a4db74fb9d1450b54bb11e51e3..ae5568845c2dec1b65e3812f35ccf32e2392619c 100644
(file)
--- a/
builtin/branch.c
+++ b/
builtin/branch.c
@@
-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"));
}
for (i = 0; i < argc; i++, strbuf_release(&bname)) {
die(_("Couldn't look up commit object for HEAD"));
}
for (i = 0; i < argc; i++, strbuf_release(&bname)) {
- c
onst char *target
;
+ c
har *target = NULL
;
int flags = 0;
strbuf_branchname(&bname, argv[i]);
int flags = 0;
strbuf_branchname(&bname, argv[i]);
@@
-231,11
+231,11
@@
static int delete_branches(int argc, const char **argv, int force, int kinds,
}
}
}
}
- target = resolve_ref
_unsafe
(name,
-
RESOLVE_REF_READING
-
| RESOLVE_REF_NO_RECURSE
-
| RESOLVE_REF_ALLOW_BAD_NAME,
-
sha1, &flags);
+ target = resolve_ref
dup
(name,
+ RESOLVE_REF_READING
+ | RESOLVE_REF_NO_RECURSE
+ | RESOLVE_REF_ALLOW_BAD_NAME,
+ sha1, &flags);
if (!target) {
error(remote_branch
? _("remote-tracking branch '%s' not found.")
if (!target) {
error(remote_branch
? _("remote-tracking branch '%s' not found.")
@@
-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,
force)) {
ret = 1;
check_branch_commit(bname.buf, name, sha1, head_rev, kinds,
force)) {
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'"),
bname.buf);
ret = 1;
: _("Error deleting branch '%s'"),
bname.buf);
ret = 1;
-
continue
;
+
goto next
;
}
if (!quiet) {
printf(remote_branch
}
if (!quiet) {
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));
}
delete_branch_config(bname.buf);
: find_unique_abbrev(sha1, DEFAULT_ABBREV));
}
delete_branch_config(bname.buf);
+
+ next:
+ free(target);
}
free(name);
}
free(name);