[PATCH] git-branch: rename nor delete should not work when HEAD is detached.

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

 



While reviewing the latest round of 'branch --track' changes, I
noticed that we do not do anything special when renaming or
deleting a detached HEAD.  We do not have anything to rename nor
delete in this case, so instead of attempting to rename/delete
refs/heads/HEAD, we should error out.

---
 * CC'ed are not guilty parties, but people who might know the
   code better than others.

diff --git a/builtin-branch.c b/builtin-branch.c
index 06d8a8c..28d4b71 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -483,6 +483,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		die("Failed to resolve HEAD as a valid ref.");
 	if (!strcmp(head, "HEAD")) {
 		detached = 1;
+		if (rename || delete)
+			die("Cannot rename nor delete a detached HEAD");
 	}
 	else {
 		if (prefixcmp(head, "refs/heads/"))

-
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]