Skip to content

Commit 9a99c08

Browse files
Eric WongJunio C Hamano
authored andcommitted
rebase: allow --merge option to handle patches merged upstream
Enhance t3401-rebase-partial to test with --merge as well as the standard am -3 strategy. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 29f4ad8 commit 9a99c08

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

git-rebase.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ call_merge () {
8282
rv=$?
8383
case "$rv" in
8484
0)
85-
git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
85+
if test -n "`git-diff-index HEAD`"
86+
then
87+
git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
88+
fi
8689
;;
8790
1)
8891
test -d "$GIT_DIR/rr-cache" && git-rerere
@@ -110,9 +113,13 @@ finish_rb_merge () {
110113
do
111114
git-read-tree `cat "$dotest/cmt.$msgnum.result"`
112115
git-checkout-index -q -f -u -a
113-
git-commit -C "`cat $dotest/cmt.$msgnum`"
114-
115-
printf "Committed %0${prec}d" $msgnum
116+
if test -n "`git-diff-index HEAD`"
117+
then
118+
git-commit -C "`cat $dotest/cmt.$msgnum`"
119+
printf "Committed %0${prec}d" $msgnum
120+
else
121+
printf "Already applied: %0${prec}d" $msgnum
122+
fi
116123
echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
117124
sed 's/^[a-f0-9]\+ //'`
118125
msgnum=$(($msgnum + 1))

t/t3401-rebase-partial.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ test_expect_success \
3737
test_expect_success \
3838
'pick top patch from topic branch into master' \
3939
'git-cherry-pick my-topic-branch^0 &&
40-
git-checkout -f my-topic-branch
40+
git-checkout -f my-topic-branch &&
41+
git-branch master-merge master &&
42+
git-branch my-topic-branch-merge my-topic-branch
4143
'
4244

4345
test_debug \
@@ -50,4 +52,13 @@ test_expect_success \
5052
'rebase topic branch against new master and check git-am did not get halted' \
5153
'git-rebase master && test ! -d .dotest'
5254

55+
if test -z "$no_python"
56+
then
57+
test_expect_success \
58+
'rebase --merge topic branch that was partially merged upstream' \
59+
'git-checkout -f my-topic-branch-merge &&
60+
git-rebase --merge master-merge &&
61+
test ! -d .git/.dotest-merge'
62+
fi
63+
5364
test_done

0 commit comments

Comments
 (0)