Introduce Repository.MergeCommits#990
Conversation
There was a problem hiding this comment.
Couldn't we move this to repo.ObjectDatabase?
There was a problem hiding this comment.
Sure. Do you like ObjectDatabase.MergeCommits?
There was a problem hiding this comment.
However, I'm not sure about the returned parameter type. I wonder if we should return a different type (an interface?).
How would this* index behave when being added/removed anything? Does git_index_write behave nicely?
There was a problem hiding this comment.
Yeah, I think so as well. Anything that hits UpdatePhysicalIndex is going to throw. I think perhaps something that wraps an index handle but is not an index might be appropriate. I think that you want to be able to:
- Get Conflicts
- Write it to a tree
...other things?
ReadOnlyIndex?
|
@nulltoken did you have any thoughts on my question(s) about what to call this interface / concrete implementation and / or what additional things it should expose? |
|
How about something like MergeTreeResult ObjectDatabase.MergeTree(Commit one, Commit another, MergeTreeOptions options)Where |
850ee0e to
edc7dc0
Compare
|
I have updated this with some changes. |
|
Neat! Could you please update the commit message of |
There was a problem hiding this comment.
Assert.NotNull(MergeTreeStatus.Tree);
Assert.Equal(0, MergeTreeStatus.Conflicts.Count());
edc7dc0 to
d70b2e0
Compare
|
Updated with your suggestions, @nulltoken |
71d12e4 to
853bd94
Compare
|
Oops, wrote that test sloppily. Updated. |
|
@ethomson Thanks for this. One final nitpick. b2b6139 commit message states Could you please reword it so that it doesn't refer to the Index any longer? |
Provide an API to merge two commits and return the result. If successful, a new tree will be written to the object database that reflects the results of the merge. If the merge had conflicts, a ConflictCollection will be provided.
Introduce a MergeOptionsBase and a MergeAndCheckoutOptionsBase so that there's less duplication of the various options that go to merge-like things.
853bd94 to
534d4e7
Compare
|
Yeah, I updated that sloppily. Fixed. |
Introduce `Repository.MergeCommits`
This introduces
Repository.MergeCommitswhich wrapsgit_merge_commitsand is suitable for taking two commits and getting the merge results as anIndex. There's a handful of interesting details here:Repository. This meant that they always went to the repository'sIndex. I broke this and pass in theIndexthat they're supposed to pay attention to. This is probably the least contentious change.indexneeds to be freed withgit_index_free, I madeIndeximplementIDisposableso that consumers ofRepository.MergeCommitscan just wrap that in ausing. To prevent anybody from trying toDisposetheRepository.Index, I only wired upDisposefor things that came from a merge.MergeOptions,CherryPickOptionsandRevertOptionsto share a common base class. They were getting a little copy-pastey. I also pulled out thegit_merge_options-like things into their own base class so thatMergeTreeOptionscould also take advantage.I suspect there's going to be something in here for everybody to hate! :) Other suggestions for how to implement these things are welcome.