[PATCH] builtin-branch - allow deleting a fully specified branch-name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change allows, for instance
	git branch -d refs/heads/foo
to succeed. Without this patch, the code just assumes that the
given branch name should be appended to "refs/heads" or
"refs/remotes", thus attempting (and failing) in the above case
to delete "refs/heads/refs/heads/foo"

Signed-off-by: Mark Levedahl <mlevedahl@xxxxxxxxx>
---
 builtin-branch.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index ca81d72..f433bc5 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -131,7 +131,11 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
 
 		free(name);
 
-		name = xstrdup(mkpath(fmt, bname.buf));
+		if (bname.len < 5 || memcmp("refs/", bname.buf, 5))
+			name = xstrdup(mkpath(fmt, bname.buf));
+		else
+			name = xstrdup(bname.buf);
+
 		if (!resolve_ref(name, sha1, 1, NULL)) {
 			error("%sbranch '%s' not found.",
 					remote, bname.buf);
-- 
1.6.2.2.27.g034b

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]