Fix base-finding for virtual commits in recursive merge - #4487
Conversation
|
Interesting. Thanks for digging into this - this aligns pretty well with what I was seeing as well where the order of parents was reversed in the merge base calculation during recursion... but I havent yet grokked why (or more accurately where) Git is doing this. Thanks much for the test case and PR. I’m going to 🤔 on this a bit to make sure there are no other edges but i think this is likely the right fix. |
|
I noticed that this still isn't producing the same tree as I'm still investigating. |
|
It looks like your files have CR/LF line endings. Git has also changed the behavior when it produces conflict files based on inputs with CR/LF line endings. #4489 should allow us to produce the same results. |
|
After including these two fixes, we're still not producing the same ancestor for Git: With this PR: stage: 53381b95506bac4a5c859e540f3d478ad155181e: Still 👀 |
|
So We need to do this full reversal, too, to match, instead of just creating the virtual merge base with the parents reversed. If, for example, there are multiple merge bases, eg: then we need to reverse the merge base list as which would merge D+C, then merge that result with B, and that result with A. If we only reverse the parents in the virtual merge base, then we would merge A+B, but then treat it as if the parents were B and A. Then merge that with C (and treating it like its parents were C B A...) And finally merging that with D. So I'm moving the reverse logic to match git. I've cherry-picked your test data and test - modifying it to match the data that git produces. I'll open a PR. Thanks again for your investigation and the PR. |
|
I'm skeptical that your fixes will fully solve the issue (I think the behavior of merge_base_many wrt. virtual bases requires them to always be the second parameter). I'll see if I can create another repro that still fails with your changes. |
|
Well, they are the second parameter now, no? |
|
I’m very happy to have more testing - If we produce different trees than Git then that would be an issue that we should investigate and fix. |
|
I've tweaked the repro case and this still repros without the one/two switch. I'll close this and create a PR into your changes. |
No description provided.