Recursive merge: reverse the order of merge bases - #4491
Merged
Conversation
Member
Author
|
Also, I think that we should bring this base reversal change (but not the CR/LF or conflict marker changes) to backport. |
Member
|
Had the same though, thanks for taking care of it! |
Provide a simple function to reverse an oidarray.
When the commits being merged have multiple merge bases, reverse the order when creating the virtual merge base. This is for compatibility with git's merge-recursive algorithm, and ensures that we build identical trees. Git does this to try to use older merge bases first. Per 8918b0c: > It seems to be the only sane way to do it: when a two-head merge is > done, and the merge-base and one of the two branches agree, the > merge assumes that the other branch has something new. > > If we start creating virtual commits from newer merge-bases, and go > back to older merge-bases, and then merge with newer commits again, > chances are that a patch is lost, _because_ the merge-base and the > head agree on it. Unlikely, yes, but it happened to me.
Virtual base building: ensure that the virtual base is created and revwalked in the same way as git.
Our virtual commit must be the last argument to merge-base: since our
algorithm pushes _both_ parents of the virtual commit, it needs to be
the last argument, since merge-base:
> Given three commits A, B and C, git merge-base A B C will compute the
> merge base between A and a hypothetical commit M
We want to calculate the merge base between the actual commit ("two")
and the virtual commit ("one") - since one actually pushes its parents
to the merge-base calculation, we need to calculate the merge base of
"two" and the parents of one.
ethomson
force-pushed
the
ethomson/recursive
branch
from
February 4, 2018 10:30
c5ce969 to
1403c61
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When git encounters multiple merge bases during a recursive merge of two commits, it reverses the order of the merge bases before starting the recursive merge. This was introduced in 8918b0c:
I've updated the tests, with
gititself, and ensuring that we produce the same output, so many of the unit tests were changed to ensure that we created identical trees to git. With this change (along with #4488 and #4489), we now produce identical output.I have included the changes from #4488 and #4489 here to illustrate. I suggest we review and merge those and then I will rebase this on top of the updated master.