merge: fix incorrect rename detection for empty files.#6717
Merged
ethomson merged 4 commits intolibgit2:mainfrom Feb 20, 2024
Merged
merge: fix incorrect rename detection for empty files.#6717ethomson merged 4 commits intolibgit2:mainfrom
ethomson merged 4 commits intolibgit2:mainfrom
Conversation
ethomson
reviewed
Jan 15, 2024
When merging trees containing multiple empty files, make sure a rename is not detected between each empty files. For example Ancestor has files: * foo.c with content * bar.c empty Ours has: * foo.c with content * boo.c empty Theirs has: * foo.c with other content * bar.c with content merge_trees() will incorrectly apply the content of theirs's 'bar.c' in ours's boo.c' thinking 'bar.c' has been renamed to 'boo.c'. This happens because both are empty and their sha1 are the same. Thus merge_diff_mark_similarity_exact() incorrectly mark it as renamed. Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
Add a boolean option to merge_trivial() so that it can use theirs parent instead of merge base as ancestor. This will be needed in the following commit. Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
This test follow "merge: fix incorrect rename detection for empty files." commit. Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
a4d334d to
16688ef
Compare
Don't munge the "trivial" tests, those are specifically about the "trivial" resolutions for git's tree merge. (For example, adding a file in a new branch and making no changes in the HEAD branch is something that can be handled _trivially_.) For tests of rename functionality, put them in the trees::rename tests.
Member
|
👋 Thanks for the fix - sorry it's taken so long to come back to it. I did make one change, which was just to move the test out of the |
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 merging trees containing multiple empty files, make sure a rename
is not detected between each empty files.
For example
Ancestor has files:
Ours has:
Theirs has:
merge_trees()will incorrectly apply the content of theirs'sbar.cinours's
boo.cthinkingbar.chas been renamed toboo.c.This happens because both are empty and their sha1 are the same. Thus
merge_diff_mark_similarity_exact()incorrectly mark it as renamed.