Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2005-12-16 04:40:25 +0300
committerJunio C Hamano <junkio@cox.net>2005-12-16 04:56:32 +0300
commitee34518d629331dadd58b1a75294369d679eda8b (patch)
tree133a5ff65d570298f838cead26db5b6ab226ac0d /refs.c
parent06d900cf28117ad5260335ea9ab7533f223320bf (diff)
We do not like "HEAD" as a new branch name
This makes git-check-ref-format fail for "HEAD". Since the check is only executed when creating refs, the existing symbolic ref is safe. Otherwise these commands, most likely are pilot errors, would do pretty funky stuff: git checkout -b HEAD git pull . other:HEAD Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index d2aec73edc..b8fcb98dad 100644
--- a/refs.c
+++ b/refs.c
@@ -345,6 +345,11 @@ int check_ref_format(const char *ref)
if (!ch) {
if (level < 2)
return -1; /* at least of form "heads/blah" */
+
+ /* do not allow ref name to end in "HEAD" */
+ if (cp - ref > 4 && !strcmp(cp - 4, "HEAD"))
+ return -1;
+
return 0;
}
}