X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-checkout.sh;h=2c053a33c3c78f27150cdd397ad28641787abb3a;hb=4bfe1199eabb41eb1f1d67f4ee24df028eb21300;hp=4a605cd9c6d76dc99ab0574dc3571db3b64e509c;hpb=7f88c8463caa14ca397048f8e576e348ce73203a;p=git.git diff --git a/git-checkout.sh b/git-checkout.sh index 4a605cd9..2c053a33 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -17,12 +17,15 @@ while [ "$#" != "0" ]; do die "git checkout: -b needs a branch name" [ -e "$GIT_DIR/refs/heads/$newbranch" ] && die "git checkout: branch $newbranch already exists" + git-check-ref-format "heads/$newbranch" || + die "we do not like '$newbranch' as a branch name." ;; "-f") force=1 ;; *) - rev=$(git-rev-parse --verify "$arg^0") || exit + rev=$(git-rev-parse --verify "$arg^0" 2>/dev/null) || + die "I don't know any '$arg'." if [ -z "$rev" ]; then echo "unknown flag $arg" exit 1 @@ -70,7 +73,8 @@ if [ "$?" -eq 0 ]; then echo $new > "$GIT_DIR/refs/heads/$newbranch" branch="$newbranch" fi - [ "$branch" ] && ln -sf "refs/heads/$branch" "$GIT_DIR/HEAD" + [ "$branch" ] && + GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD "refs/heads/$branch" rm -f "$GIT_DIR/MERGE_HEAD" else exit 1