rebase-i-p: do not include non-first-parent commits touching UPSTREAM
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>
Stephen Haberman committed
Oct 15, 2008 at 02:44 UTC
d80d6bc146232d81f1bb4bc58e5d89263fd228d4
1 file changed
+2
-1
git-rebase--interactive.sh
+2
-1
@@ -583,6 +583,7 @@ first and then run 'git rebase --continue' again."
583
# parents to rewrite and skipping dropped commits would
584
# prematurely end our probe
585
MERGES_OPTION=
586
+ first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
587
else
588
MERGES_OPTION="--no-merges --cherry-pick"
589
fi
@@ -603,7 +604,7 @@ first and then run 'git rebase --continue' again."
604
preserve=t
605
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
606
do
606
- if test -f "$REWRITTEN"/$p
607
+ if test -f "$REWRITTEN"/$p -a \( $p != $UPSTREAM -o $sha1 = $first_after_upstream \)
608
then
609
preserve=f
610
fi