-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Support union merges via .gitattributes file #3497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1712,6 +1733,10 @@ int git_merge__iterators( | |||
git_vector_foreach(&changes, i, conflict) { | |||
int resolved = 0; | |||
|
|||
/* Check for merge options in .gitattributes */ | |||
if ((error = git_merge__lookup_file_favor(repo, conflict->our_entry.path, &opts) < 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this modifies opts
in place, won't the newly set opts->file_favor
bleed into conflict resolution for other files, processed after the file that had the attribute set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point. I've updated the code to not do that.
94f140f
to
6859aca
Compare
Is there anything else needed on this PR? Please let us know if we can help. |
Sorry about the delay! A couple of things, most are stylistic and minor:
|
ee96e34
to
18f9489
Compare
Thanks, @ethomson. I've updated the PR based on your comments. I actually think the right way to support different I did attempt to write a test for this case, but because I added a |
Neat! I think that the easiest way to test this would be to create a test that writes the gitattributes file before doing the merge. (As you point out - a lot of the other tests depend on the current state of those test repositories.) You should be able to do something as simple as:
(Replacing the path and contents with something more appropriate.) |
1977b65
to
9e9b6d2
Compare
Thanks for the tip, @ethomson! I've updated the PR with a test. |
9e9b6d2
to
001d4c8
Compare
001d4c8
to
6d4b5c1
Compare
@ethomson, would you mind taking a look? Thank you. |
Somehow my test case vanished when I rebased. Working on that... |
Ok, fixed. Looks like the rebase introduced a bug that prevented this functionality from working that was caught by the test. |
@ethomson Friendly reminder to review this pull request :) |
Hi - sorry about the delay. Thanks so much for the fine work here. As I reviewed this, I must admit that I felt very bad that we were going to open up As a result, I opened #3564 that includes this as well as Thanks again! |
@ethomson Thanks for implementing custom merge support--even better! I suppose we can close this PR then? |
Sounds good, I rolled both these commits into that PR, so I'll go ahead and close this one. Thanks again for the fine work. |
When a repository has a
.gitattributes
file that has amerge=union
line for a CHANGELOG file, for example, libgit2 ignores this file and reports a conflict when git doesn't have one. This is partially to fix #2180.I tried adding a test for this, but adding
.gitattributes
file to themerge-resolve
directory seems to cause additional failures due to the change in entries. I wanted to get feedback on this before spending even more time on that.