rebase: do not get confused in fast-forward situation.
[git.git] / git-rebase.sh
index 638ff0d..c1619ff 100755 (executable)
@@ -3,8 +3,11 @@
 # Copyright (c) 2005 Junio C Hamano.
 #
 
+USAGE='<upstream> [<head>]'
 . git-sh-setup
 
+case $# in 1|2) ;; *) usage ;; esac
+
 # Make sure we do not have .dotest
 if mkdir .dotest
 then
@@ -19,7 +22,7 @@ you still have something valuable there.'
 fi
 
 # The other head is given.  Make sure it is valid.
-other=$(git-rev-parse --verify "$1^0") || exit
+other=$(git-rev-parse --verify "$1^0") || usage
 
 # Make sure we have HEAD that is valid.
 head=$(git-rev-parse --verify "HEAD^0") || exit
@@ -36,7 +39,8 @@ esac
 # If the branch to rebase is given, first switch to it.
 case "$#" in
 2)
-       git-checkout "$2" || exit
+       head=$(git-rev-parse --verify "$2^") || usage
+       git-checkout "$2" || usage
 esac
 
 # If the HEAD is a proper descendant of $other, we do not even need