]> rtime.felk.cvut.cz Git - git.git/blobdiff - git-rebase--interactive.sh
rebase -i: teach --onto A...B syntax
[git.git] / git-rebase--interactive.sh
index 23ded48322bf795b06aa40e4684bc710c8232549..f7ae02ccb57a4dbe4e7efc38f9c4615237704904 100755 (executable)
@@ -482,6 +482,25 @@ get_saved_options () {
        test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
 }
 
+LF='
+'
+parse_onto () {
+       case "$1" in
+       *...*)
+               if      left=${1%...*} right=${1#*...} &&
+                       onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
+               then
+                       case "$onto" in
+                       ?*"$LF"?* | '')
+                               exit 1 ;;
+                       esac
+                       echo "$onto"
+                       exit 0
+               fi
+       esac
+       git rev-parse --verify "$1^0"
+}
+
 while test $# != 0
 do
        case "$1" in
@@ -589,7 +608,7 @@ first and then run 'git rebase --continue' again."
                ;;
        --onto)
                shift
-               ONTO=$(git rev-parse --verify "$1") ||
+               ONTO=$(parse_onto "$1") ||
                        die "Does not point to a valid commit: $1"
                ;;
        --)