git-rebase--interactive.sh: preserve-merges fails on merges created with no-ff
commitc192f9c865dbdae48c0400d717581d34cd315fb8
authorAndrew Wong <andrew.kw.w@gmail.com>
Thu, 28 Apr 2011 04:35:55 +0000 (28 00:35 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Apr 2011 16:56:55 +0000 (28 09:56 -0700)
tree9a12ca5c3d38222b9434727cb3fe3f7ef02f4493
parent4fec83045bdc53ed9d3ff71ed099e3e6992b5c56
git-rebase--interactive.sh: preserve-merges fails on merges created with no-ff

'git rebase' uses 'git merge' to preserve merges (-p).  This preserves
the original merge commit correctly, except when the original merge
commit was created by 'git merge --no-ff'.  In this case, 'git rebase'
will fail to preserve the merge, because during 'git rebase', 'git
merge' will simply fast-forward and skip the commit.  For example:

               B
              / \
             A---M
            /
    ---o---O---P---Q

If we try to rebase M onto P, we lose the merge commit and this happens:

                 A---B
                /
    ---o---O---P---Q

To correct this, we simply do a "no fast-forward" on all merge commits
when rebasing.  Since by the time we decided to do a 'git merge' inside
'git rebase', it means there was a merge originally, so 'git merge'
should always create a merge commit regardless of what the merge
branches look like. This way, when rebase M onto P from the above
example, we get:

                   B
                  / \
                 A---M
                /
    ---o---O---P---Q

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase--interactive.sh
t/t3409-rebase-preserve-merges.sh