git status: Show uncommitted submodule changes too when enabled
[gitweb.git] / git-rebase.sh
index 6503113a84e6e01e15bfcddd427c359c597cd7d1..3de0942c0fa604fd0aed8561e3f2727c0a7887e5 100755 (executable)
@@ -419,22 +419,27 @@ fi
 
 # Make sure the branch to rebase onto is valid.
 onto_name=${newbase-"$upstream_name"}
-if     left=$(expr "$onto_name" : '\(.*\)\.\.\.') &&
-       right=$(expr "$onto_name" : '\.\.\.\(.*\)$') &&
-       : ${left:=HEAD} ${right:=HEAD} &&
-       onto=$(git merge-base "$left" "$right")
-then
-       case "$onto" in
-       ?*"$LF"?*)
-               die "$onto_name: there are more than one merge bases"
-               ;;
-       '')
+case "$onto_name" in
+*...*)
+       if      left=${onto_name%...*} right=${onto_name#*...} &&
+               onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
+       then
+               case "$onto" in
+               ?*"$LF"?*)
+                       die "$onto_name: there are more than one merge bases"
+                       ;;
+               '')
+                       die "$onto_name: there is no merge base"
+                       ;;
+               esac
+       else
                die "$onto_name: there is no merge base"
-               ;;
-       esac
-else
+       fi
+       ;;
+*)
        onto=$(git rev-parse --verify "${onto_name}^0") || exit
-fi
+       ;;
+esac
 
 # If a hook exists, give it a chance to interrupt
 run_pre_rebase_hook "$upstream_arg" "$@"
@@ -484,7 +489,7 @@ orig_head=$branch
 mb=$(git merge-base "$onto" "$branch")
 if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
        # linear history?
-       ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null
+       ! (git rev-list --parents "$onto".."$branch" | sane_grep " .* ") > /dev/null
 then
        if test -z "$force_rebase"
        then
@@ -513,7 +518,7 @@ then
 fi
 
 # If the $onto is a proper descendant of the tip of the branch, then
-# we just fast forwarded.
+# we just fast-forwarded.
 if test "$mb" = "$branch"
 then
        say "Fast-forwarded $branch_name to $onto_name."