Skip to content

Commit

Permalink
We do not like "HEAD" as a new branch name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Dec 16, 2005
1 parent 06d900c commit ee34518
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit ee34518

Please sign in to comment.