diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-12 15:34:35 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-12 15:34:35 -0700 |
commit | d1de693d0d83b2d0d12320312ae523c7711bf627 (patch) | |
tree | 5cb1723525e1addde44e716de2471efc5826aa3b /builtin | |
parent | Merge branch 'jc/submodule-anchor-git-dir' (diff) | |
parent | symbolic-ref -d: do not allow removal of HEAD (diff) | |
download | tgif-d1de693d0d83b2d0d12320312ae523c7711bf627.tar.xz |
Merge branch 'jc/forbid-symbolic-ref-d-HEAD'
"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')
-rw-r--r-- | builtin/symbolic-ref.c | 2 |
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); } |