summaryrefslogtreecommitdiff
path: root/builtin/symbolic-ref.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-09-19 13:51:40 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-09-19 13:51:41 -0700
commitd6645312ff82245a8e9bc8187ad16c57456bff38 (patch)
treebcbef7c70559fa152cecd06a9242145ecb5c374f /builtin/symbolic-ref.c
parentMerge branch 'jc/submodule-anchor-git-dir' into maint (diff)
parentsymbolic-ref -d: do not allow removal of HEAD (diff)
downloadtgif-d6645312ff82245a8e9bc8187ad16c57456bff38.tar.xz
Merge branch 'jc/forbid-symbolic-ref-d-HEAD' into maint
"git symbolic-ref -d HEAD" happily removes the symbolic ref, but the resulting repository becomes an invalid one. Teach the command to forbid removal of HEAD. * jc/forbid-symbolic-ref-d-HEAD: symbolic-ref -d: do not allow removal of HEAD
Diffstat (limited to 'builtin/symbolic-ref.c')
-rw-r--r--builtin/symbolic-ref.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 9c29a64e43..96eed94468 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -56,6 +56,8 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
ret = check_symref(argv[0], 1, 0, 0);
if (ret)
die("Cannot delete %s, not a symbolic ref", argv[0]);
+ if (!strcmp(argv[0], "HEAD"))
+ die("deleting '%s' is not allowed", argv[0]);
return delete_ref(argv[0], NULL, REF_NODEREF);
}