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/"))