]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-rebase--interactive.sh
rebase -i -p: handle index and workdir correctly
[git.git] / git-rebase--interactive.sh
index da79a2456814e4038a42238e0865d8950c14dff0..58126bd80cd73993c6cedd548e200c0fa461a8af 100755 (executable)
@@ -145,7 +145,16 @@ pick_one () {
 }
 
 pick_one_preserving_merges () {
-       case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
+       fast_forward=t
+       case "$1" in
+       -n)
+               fast_forward=f
+               sha1=$2
+               ;;
+       *)
+               sha1=$1
+               ;;
+       esac
        sha1=$(git rev-parse $sha1)
 
        if test -f "$DOTEST"/current-commit
@@ -157,7 +166,6 @@ pick_one_preserving_merges () {
        fi
 
        # rewrite parents; if none were rewritten, we can fast-forward.
-       fast_forward=t
        preserve=t
        new_parents=
        for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
@@ -174,12 +182,16 @@ pick_one_preserving_merges () {
                                new_parents="$new_parents $new_p"
                                ;;
                        esac
+               else
+                       new_parents="$new_parents $p"
                fi
        done
        case $fast_forward in
        t)
                output warn "Fast forward to $sha1"
                test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
+               output git reset --hard $sha1 ||
+                       die "Cannot fast forward to $sha1"
                ;;
        f)
                test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
@@ -275,7 +287,7 @@ do_next () {
                        die_with_patch $sha1 "Could not apply $sha1... $rest"
                make_patch $sha1
                : > "$DOTEST"/amend
-               warn
+               warn "Stopped at $sha1... $rest"
                warn "You can amend the commit now, with"
                warn
                warn "  git commit --amend"