]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-rebase--interactive.sh
Merge branch 'jc/maint-1.6.1-checkout-m-custom-merge'
[git.git] / git-rebase--interactive.sh
index 0bd3bf78b8563f29a24dbc7dcc4ef308b3381157..1560e84bd5d06345dd3976ed55c1cfb8af51b41e 100755 (executable)
@@ -322,7 +322,7 @@ make_squash_message () {
 }
 
 peek_next_command () {
-       sed -n "1s/ .*$//p" < "$TODO"
+       sed -n -e "/^#/d" -e "/^$/d" -e "s/ .*//p" -e "q" < "$TODO"
 }
 
 do_next () {
@@ -495,6 +495,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
@@ -602,7 +621,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"
                ;;
        --)
@@ -779,7 +798,7 @@ EOF
 
                cp "$TODO" "$TODO".backup
                git_editor "$TODO" ||
-                       die "Could not execute editor"
+                       die_abort "Could not execute editor"
 
                has_action "$TODO" ||
                        die_abort "Nothing to do"