diff options
author | Junio C Hamano <junkio@cox.net> | 2005-11-02 12:17:47 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-11-02 16:50:58 -0800 |
commit | 13d1cc3604a1a64cb5a6025bba8af8b74a373963 (patch) | |
tree | cea2bfd5cdf2af19f8b8c6011201bdd81a759831 /git-checkout.sh | |
parent | 4ccafd7a02fd9905cc5382b2c1d5abdb11a7525a (diff) | |
download | git-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-checkout.sh')
-rwxr-xr-x | git-checkout.sh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/git-checkout.sh b/git-checkout.sh index cb33fdc7e2..4c08f36b59 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -126,7 +126,9 @@ fi # if [ "$?" -eq 0 ]; then if [ "$newbranch" ]; then - echo $new > "$GIT_DIR/refs/heads/$newbranch" + leading=`expr "refs/heads/$newbranch" : '\(.*\)/'` && + mkdir -p "$GIT_DIR/$leading" && + echo $new >"$GIT_DIR/refs/heads/$newbranch" || exit branch="$newbranch" fi [ "$branch" ] && |