Skip to content

Commit 714fff2

Browse files
author
Linus Torvalds
committed
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?
1 parent 79162bb commit 714fff2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-checkout-script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ while [ "$#" != "0" ]; do
1313
force=1
1414
;;
1515
*)
16-
rev=$(git-rev-parse --verify --revs-only "$arg")
16+
rev=$(git-rev-parse --verify --revs-only "$arg^0") || exit
1717
if [ -z "$rev" ]; then
1818
echo "unknown flag $arg"
1919
exit 1

0 commit comments

Comments
 (0)