summaryrefslogtreecommitdiff
path: root/git-checkout.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-checkout.sh')
-rwxr-xr-xgit-checkout.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/git-checkout.sh b/git-checkout.sh
index dd477245fb..119bca1ffb 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
shift
[ -z "$newbranch" ] &&
die "git checkout: -b needs a branch name"
- [ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
+ git-show-ref --verify --quiet -- "refs/heads/$newbranch" &&
die "git checkout: branch $newbranch already exists"
git-check-ref-format "heads/$newbranch" ||
die "git checkout: we do not like '$newbranch' as a branch name."
@@ -51,7 +51,8 @@ while [ "$#" != "0" ]; do
fi
new="$rev"
new_name="$arg^0"
- if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
+ if git-show-ref --verify --quiet -- "refs/heads/$arg"
+ then
branch="$arg"
fi
elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)