@matheusbsbs / matheus-bagliano / commits / 305e22c36e
Fork 0

Teach "git checkout" to use git-show-ref

That way, it doesn't care how the refs are stored any more Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Sep 15, 2006 at 14:56 UTC 305e22c36e674924de6decb29e8a4c22292b5054
1 file changed +3 -2
git-checkout.sh
+3 -2
@@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
22 shift
23 [ -z "$newbranch" ] &&
24 die "git checkout: -b needs a branch name"
25 - [ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
25 + git-show-ref --verify --quiet -- "refs/heads/$newbranch" &&
26 die "git checkout: branch $newbranch already exists"
27 git-check-ref-format "heads/$newbranch" ||
28 die "git checkout: we do not like '$newbranch' as a branch name."
@@ -51,7 +51,8 @@ while [ "$#" != "0" ]; do
51 fi
52 new="$rev"
53 new_name="$arg^0"
54 - if [ -f "$GIT_DIR/refs/heads/$arg" ]; then
54 + if git-show-ref --verify --quiet -- "refs/heads/$arg"
55 + then
56 branch="$arg"
57 fi
58 elif rev=$(git-rev-parse --verify "$arg^{tree}" 2>/dev/null)