Skip to content

Commit 18f29fc

Browse files
rsahlberggitster
authored andcommitted
branch -d: simplify by using RESOLVE_REF_READING
When "git branch -d" reads the branch it is about to delete, it used to avoid passing the RESOLVE_REF_READING ('treat missing ref as error') flag because a symref pointing to a nonexistent ref would show up as missing instead of as something that could be deleted. To check if a ref is actually missing, we then check - is it a symref? - if not, did it resolve to null_sha1? Now we pass RESOLVE_REF_NO_RECURSE and the correct information is returned for a symref even when it points to a missing ref. Simplify by relying on RESOLVE_REF_READING. No functional change intended. Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62a2d52 commit 18f29fc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/branch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,11 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
236236
free(name);
237237

238238
name = mkpathdup(fmt, bname.buf);
239-
target = resolve_ref_unsafe(name, RESOLVE_REF_NO_RECURSE,
239+
target = resolve_ref_unsafe(name,
240+
RESOLVE_REF_READING
241+
| RESOLVE_REF_NO_RECURSE,
240242
sha1, &flags);
241-
if (!target ||
242-
(!(flags & REF_ISSYMREF) && is_null_sha1(sha1))) {
243+
if (!target) {
243244
error(remote_branch
244245
? _("remote branch '%s' not found.")
245246
: _("branch '%s' not found."), bname.buf);

0 commit comments

Comments
 (0)