From: Linus Torvalds Date: Tue, 12 Jul 2005 01:32:30 +0000 (-0700) Subject: Make "git checkout" verify that the argument refers to a commit X-Git-Tag: v0.99.1~55 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=714fff2aa8979c5dd169481909a364a860481f0e;p=git.git Make "git checkout" verify that the argument refers to a commit We still need to create a new branch if it didn't refer to an existing branch, otherwise our HEAD will continue to point to something totally different than what we just checked out. I'll need to think about it. Maybe only do it with "-f" and force it to the "master" branch? --- diff --git a/git-checkout-script b/git-checkout-script index bf52e3bb..48e1da93 100755 --- a/git-checkout-script +++ b/git-checkout-script @@ -13,7 +13,7 @@ while [ "$#" != "0" ]; do force=1 ;; *) - rev=$(git-rev-parse --verify --revs-only "$arg") + rev=$(git-rev-parse --verify --revs-only "$arg^0") || exit if [ -z "$rev" ]; then echo "unknown flag $arg" exit 1