On 28/02/2018 02:33, Igor Djordjevic wrote: > > This seems to be working inside my (too trivial?) test case, for > interactive adding, dropping, and amending of rebased commits, > resulting "rebased" merge containing all the added/modified/dropped > changes, plus the original merge amendment, all as expected :P In case anyone has a wish to examine my (now pretty messy) test script, here it is - sorry for not having time to clean it up! :( What I get when I diff original and "rebased" merge is this: diff --git a/test.txt b/test.txt index a82470b..d458032 100644 --- a/test.txt +++ b/test.txt @@ -1,10 +1,14 @@ +A21 +A22 +A23 +A24 +A25 A1 A2 -B11 +B1111 A3 A4 A5 -B12 A6 A7 A8 @@ -14,6 +18,7 @@ A10 A11 A12 A13 +BX A14 B2 A15 ... where A21 to A25 are additions due to new base, B11 was interactively amended to B1111, B12 was interactively dropped, and BX interactively added :) We don`t see line X here, being an "evil merge" amendment being correctly preserved from original merge commit (thus not a difference). If we do `git show` of the "rebased" merge, we get this, as expected: diff --cc test.txt index b173cef,fad39a8..d458032 --- a/test.txt +++ b/test.txt @@@ -13,6 -13,6 +13,7 @@@ A A7 A8 A9 ++X A10 A11 A12 Regards, Buga -- 8< -- #!/bin/sh # rm -rf ./.git # rm -f ./test.txt git init touch ./test.txt git add -- test.txt for i in {1..20} do echo A$i >>test.txt git commit -am "A$i" done git checkout -b b1 sed -i '3iB11' test.txt git commit -am "B11" sed -i '7iB12' test.txt git commit -am "B12" git checkout -b b2 HEAD^ sed -i '16iB2' test.txt git commit -am "B2" git checkout -b merge b1 git merge --no-commit b2 sed -i '12iX' test.txt # amend merge commit git commit -am "M" git tag original-merge git checkout master for i in {1..5} do j=`expr "$i" + 20` sed -i "${i}iA${j}" test.txt git commit -am "A$j" done # simple/naive demonstration of proposed merge rebasing logic # using described "Trivial Merge" (TM, or "Angel Merge"), # preserving merge commit manual amendments, but still respecting # interactively rebased added/modified/dropped commits :) # read -p "Press enter to continue" git checkout b1 git cherry-pick -m1 original-merge && git tag U1 git reset --hard HEAD^^ # drop U1 and last b1 commit sed -i '/B11/c\B1111' test.txt git commit -a --amend --no-edit git rebase master git cherry-pick U1 && git tag U1-prime # read -p "Press enter to continue" git checkout b2 git cherry-pick -m2 original-merge && git tag U2 git reset --hard HEAD^ # drop U2 git rebase master sed -i '20iBX' test.txt git commit -am "BX" # add new commit git cherry-pick U2 && git tag U2-prime git diff U1 U1-prime | git apply --3way && git commit -m "U2-second" && git tag U2-second git checkout b1 git diff U2 U2-prime | git apply --3way && git commit -m "U1-second" && git tag U1-second # read -p "Press enter to continue" git branch -f merge b1 git checkout merge git merge b2 --no-commit git commit -a --reuse-message original-merge git tag angel-merge # read -p "Press enter to continue" git reset --hard b1^ git read-tree --reset angel-merge git update-ref refs/heads/merge "$(git show -s --format=%B original-merge | git commit-tree "$(git write-tree)" -p "$(git rev-parse b1^^)" -p "$(git rev-parse b2^^)")" git tag -f angel-merge git checkout angel-merge . git branch -f b1 b1^^ git branch -f b2 b2^^ # show resulting graph echo git log --all --decorate --oneline --graph # comparison between original merge and rebased merge, # showing merge commit amendment "X" being preserved during rebase # (not shown in diff) echo echo 'diff original-merge angel-merge:' git diff original-merge angel-merge