summaryrefslogtreecommitdiff
path: root/git-branch.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-02 12:17:47 -0800
committerJunio C Hamano <junkio@cox.net>2005-11-02 16:50:58 -0800
commit13d1cc3604a1a64cb5a6025bba8af8b74a373963 (patch)
treecea2bfd5cdf2af19f8b8c6011201bdd81a759831 /git-branch.sh
parent4ccafd7a02fd9905cc5382b2c1d5abdb11a7525a (diff)
downloadgit-13d1cc3604a1a64cb5a6025bba8af8b74a373963.tar.gz
Do not fail on hierarchical branch names.
"git-checkout -b frotz/nitfol master" failed to create $GIT_DIR/refs/heads/frotz/nitfol but went ahead and updated $GIT_DIR/HEAD to point at it, resulting in a corrupt repository. Exit when we cannot create the new branch with an error status. While we are at it, there is no reason to forbid subdirectories in refs/heads, so make sure we handle that correctly. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-branch.sh')
-rwxr-xr-xgit-branch.sh2
1 files changed, 2 insertions, 0 deletions
diff --git a/git-branch.sh b/git-branch.sh
index e2db9063d4..67f113acb9 100755
--- a/git-branch.sh
+++ b/git-branch.sh
@@ -102,4 +102,6 @@ rev=$(git-rev-parse --verify "$head") || exit
git-check-ref-format "heads/$branchname" ||
die "we do not like '$branchname' as a branch name."
+leading=`expr "refs/heads/$branchname" : '\(.*\)/'` &&
+mkdir -p "$GIT_DIR/$leading" &&
echo $rev > "$GIT_DIR/refs/heads/$branchname"