-
Notifications
You must be signed in to change notification settings - Fork 899
Introduce basic merging #579
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
<PlatformTarget>x86</PlatformTarget> | ||
<ErrorReport>prompt</ErrorReport> | ||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> |
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.
Do we really need a dedicated x86 target?
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.
Sorry about that, a cherry-pick casualty.
This is very exciting to see! I'm excited to see merge in libgit2#. |
|
||
repo.MergeOnto(repo.Branches["FirstBranch"].Tip); | ||
|
||
repo.Commit("Merge First+Second"); |
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.
Could you please add some assertions here?
Maybe:
- Number of parents of the merge commit
- Ensuring the Commit.Tree contains the expected files
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.
In. I'm thinking there should probably be some tests related to the merge result if it's felt that its necessary?
@CrumblyCake Wow! Nice one! @ethomson Thanks for jumping in, MergeMaster™ ❤️ |
On a slightly sadder note, it looks like Travis isn't as happy as we're are.
|
I suspect it will pass after some of the recommended signature cleanups. On Thu, Dec 5, 2013 at 11:54 AM, nulltoken [email protected] wrote:
|
@@ -1,6 +1,7 @@ | |||
using System.Linq; | |||
using LibGit2Sharp.Tests.TestHelpers; | |||
using Xunit; | |||
using System; |
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.
Is this using necessary? if so, maybe sort it with the other System.* statements?
No worries there... Welcome to the party! |
MergeFixture: Cleaned usings & removed unused method. NativeMethods: Used suggested signature for git_merge. Added ref+fetchhead git_merge_froms just in case they could be used in future (Should I revert this, I'm not sure on your rules about unused methods in a wrapper?) Proxy: Split git_merge and git_merge_from_oid into separate methods and used suggested signature. Fixed the result checking for boolean C calls in is_uptodate and is_fastforward. GitMergeResult: Renamed to MergeResult, put loading prop values in constructor. Repository: Replaced MergeOnto with Merge.
MergeResult: Fixed up bad reference + added FastForwardOid prop Repository: Wrapped MergeHead and MergeResult handles in usings.
namespace LibGit2Sharp.Core | ||
{ | ||
[Flags] | ||
internal enum MergeFlags |
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.
@ethomson Can one combine those flags?
IOW, would GIT_MERGE_NO_FASTFORWARD | GIT_MERGE_FASTFORWARD_ONLY
make sense?
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.
One cannot, it definitely doesn't make sense.
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.
But(!) my thinking is that this is a bitfield and we may have other options that could be combined later. You can't combine GIT_MERGE_NO_FASTFORWARD
with GIT_MERGE_FASTFORWARD_ONLY
but maybe you could combine it with something else like GIT_MERGE_DONT_WRITE_CRAPPY_METADATA_FILES
or something.
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.
@ethomson - This is not currently represented as a bit field in libgit2. If that is the intention of this type, should we update the libgit2 representation?
In addition, should there be a named default value (both here and in libgit2) - GIT_MERGE_DEFAULT = 0
?
@CrumblyCake Do you think you could also add a test putting under the light a failed merged when a conflict occur? @ethomson Have we got actually all we need to actually resolve the merge and perform the merge commit? |
@nulltoken Will do for next commit, I've hit a few snags that I'll need some light shed on. Separately, while its possible (commenting on the CheckoutStrategy.GIT_CHECKOUT_USE_OURS indicates it and THEIRS are unimplemented but they work fine), the process to checkout ours/theirs on a conflict is a bit arduous when I was thinking it could just be something like CheckoutOurs(Conflict conflict) or Conflict.Ours.Checkout(). Would this be the place to put a method like this or should it be kept separate from the topic? |
Indeed, that looks like a bug. An oversight on my part. You're welcome to file an issue in libgit2 for this, unfortunately I will not be able to take a look at this today.
This is the expected behavior. A fast-forward is not a merge, so we stop and tell you that you are eligible to fast-forward to that commit. At that point you just do a checkout.
I'm not certain, to be honest; @nulltoken would have a better sense of how you should identify a path to checkout and specify which version of a file to checkout. |
@@ -1,5 +1,5 @@ | |||
using System.Linq; | |||
using LibGit2Sharp.Tests.TestHelpers; | |||
using LibGit2Sharp.Tests.TestHelpers; |
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.
small style point: Normally, we have sorted the System using directives above all other directives. This default sorting behavior has changed in Visual Studio 2013.
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.
Man, it just looks wrong to have System anywhere but sorted first. :(
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.
yeah - at least there is a option to sort these first.
Put an implicit fast forward into the Merge method in Repository.cs, cleaned up usings/comments, removed GitMergeHead and made other suggested changes from github.
/// </summary> | ||
/// <param name="commit">The commit to use as a reference for the changes that should be merged into HEAD.</param> | ||
/// <returns>The result of the performed merge <see cref="MergeResult"/>.</returns> | ||
public MergeResult Merge(Commit commit) |
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.
I was thinking about I would expect this method to return... If this method is going to handle the committing of the merge, then maybe callers of this method would only be interested in what happened as a result of this method call - for instance, maybe returning an enum type with possible values such as of UpToDate
, NormalMerge
, FastForwardMerge
, and Conflict
would be sufficient. Maybe there are other use cases as well...
At some point, I can see this method getting a MergeOptions
parameter as well, to control behaviors such as the type of acceptable merges (Normal only, Fast Forward only), whether to actually commit the merge or not, etc... Not needed at this time, but might be nice in the future.
I think these changes are looking good, and I am very excited for this functionality to be included in LibGit2Sharp as well! Thanks! |
namespace LibGit2Sharp.Core | ||
{ | ||
[Flags] | ||
internal enum MergeTreeFlags |
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.
nit: Most of the enums are of the form Git* (i.e. GitMergeTreeFlags
) (although there are a couple of exceptions to this pattern).
@CrumblyCake - I have been thinking about merge a bit more and made a commit to capture some of my thoughts and things I wanted to try out at: e2523bb. How do you feel about the direction of those changes? That series of commits were also rebased on top of latest vNext, in order to get some "fixes" for tests that have recently started to fail. /cc @nulltoken |
@jamill Wow! Thanks a lot for giving a hand here! @CrumblyCake How do you feel about @jamill's proposed changes? |
@jamill & @nulltoken - |
Closed as #608 has been merged |
Hey not sure if this would be useful, I needed it for something I was doing and figured it could, at the least, be useful as a base for starting to get merging in. I'm not sure about how a caller should interact with the merging stuff, so I just did a mix of how I would want to use it/how similar stuff is done. Please feel free to tear me apart because I screwed up somewhere, very new to libgit2sharp + git/github.