Code

rebase-i-p: do not include non-first-parent commits touching UPSTREAM
authorStephen Haberman <stephen@exigencecorp.com>
Wed, 15 Oct 2008 07:44:39 +0000 (02:44 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Oct 2008 16:23:54 +0000 (09:23 -0700)
This covers an odd boundary case found by Avi Kivity's script where a branch
coming off of UPSTREAM is merged into HEAD. Initially it show up in
UPSTREAM..HEAD, but technically UPSTREAM is not moving, the rest of head is, so
we should not need to rewrite the merge.

This adds a check saying we can keep `preserve=t` if `p=UPSTREAM`...unless this
is the first first-parent commit in our UPSTREAM..HEAD rev-list, which could
very well point to UPSTREAM, but we still need to consider it as rewritten so we
start pulling in the rest of the UPSTREAM..HEAD commits that point to it.

Signed-off-by: Stephen Haberman <stephen@exigencecorp.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--interactive.sh

index 851066f0f47a6c850c649112a88a060fc3ecb99a..495f554b6576cfb1f32d94f319b325a4de9d648d 100755 (executable)
@@ -583,6 +583,7 @@ first and then run 'git rebase --continue' again."
                        # parents to rewrite and skipping dropped commits would
                        # prematurely end our probe
                        MERGES_OPTION=
+                       first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
                else
                        MERGES_OPTION="--no-merges --cherry-pick"
                fi
@@ -603,7 +604,7 @@ first and then run 'git rebase --continue' again."
                                preserve=t
                                for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
                                do
-                                       if test -f "$REWRITTEN"/$p
+                                       if test -f "$REWRITTEN"/$p -a \( $p != $UPSTREAM -o $sha1 = $first_after_upstream \)
                                        then
                                                preserve=f
                                        fi