8000 Update to libgit2 6aa06b6 by carlosmn · Pull Request #1237 · libgit2/libgit2sharp · GitHub
[go: up one dir, main page]

Skip to content

Update to libgit2 6aa06b6 #1237

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

Merged
merged 4 commits into from
Feb 22, 2016
Merged

Update to libgit2 6aa06b6 #1237

merged 4 commits into from
Feb 22, 2016

Conversation

carlosmn
Copy link
Member
@carlosmn carlosmn commented Dec 1, 2015

Update to 6aa06b6 with the speed fixes for merge and tree parsing.

{ 8000
/// <summary>
/// Defaults
/// </summary>
GIT_MERGE_FILE_DEFAULT = 0,

/// <summary>
/// <summ ary>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a space error

@whoisj
Copy link
whoisj commented Dec 2, 2015

generally looks good - left minor comments.

@@ -35,7 +35,7 @@ internal struct GitMergeOpts
/// <summary>
/// File merging flags.
/// </summary>
public GitMergeFileFlags FileFlags;
public GitMergeFileFlag FileFlags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct needs a public uint RenameThreshold between the SimilarityMetric and the MergeFileFavorFlags. (Sorry for the breaking change.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that in the diff.

@nulltoken
Copy link
Member

Shouldn't package.config be updated to 1.0.114?

@carlosmn
Copy link
Member Author
carlosmn commented Dec 2, 2015

Shouldn't package.config be updated to 1.0.114?

It should, but hotel wifi is its own special circle of hell, so after nuget failed to upload the package a few times, I decided I'd do it after I get back home.

@carlosmn carlosmn force-pushed the cmn/lg2-update branch 6 times, most recently from 2b1fd22 to 913eed2 Compare December 9, 2015 13:29
@carlosmn
Copy link
Member Author
carlosmn commented Dec 9, 2015

I've now also added a ConflictInMergeException to throw when we return GIT_EMERGECONFLICT. On the next release, we can move that over to MergeConflictException and deprecate this one.

@@ -23,6 +23,16 @@ protected MergeOptionsBase()
public bool FindRenames { get; set; }

/// <summary>
/// If set, fail on the first conflict. No merged index will be created.
/// </summary>
public bool FailOnConflict { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this switch actually triggers a throw, maybe should we describe the thrown exception in the xml doc? and maybe rename this member as ThrowsOnFirstConflict ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (explanation), but I'd rather keep the libgit2 name for the option. It gets harder to know what you're doing if they don't match.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to help to user, shouldn't we describe the type of exception that's going to be thrown?

It gets harder to know what you're doing if they don't match.

I agree, from a troubleshooting perspective, and we've done this for internal types.

However, Throws means something very clear in .NET land. Fail doesn't, and I'd rather stick with the idioms of the language when we're exposing a public type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new text does show which exception we throw. But there's of course the issue of whether we should throw at all, or if this should just be part of the merge result we return.

@carlosmn carlosmn changed the title [WIP] Update to libgit2 a27f31d8 Update to libgit2 a27f31d8 Dec 10, 2015
Instead of throwing an exception, return the merge error in the normal
way, as this early failure was requested by the user and thus not an
exceptional circunstance.
@carlosmn
Copy link
Member Author

I figured throwing when the user explicitly asked us to error out is Bad Form, so now I've made it so we return the normal error condition, just without any actual conflict listing.

@nulltoken
Copy link
Member

I figured throwing when the user explicitly asked us to error out is Bad Form, so now I've made it so we return the normal error condition, just without any actual conflict listing.

I'm not sold on this. Thats looks like a disguised scenario for "Can I merge without a conflict?". And returning an empty list of conflicts seems like very weird.

The ObjectDatabase already exposes a CanMergeWithoutConflict() method. How about moving the fail-fast optimization there and not publicly exposing this option?

This stops at the first error so we can return negatives quicker.
@carlosmn
Copy link
Member Author

This is indeed a feature intended for that scenario, and yes we should make the already-existing CanMergeWithoutConflict() method take advantage of this. But I don't think that this means we should stop consumers of the library from using it in their own code. We use the library because of the control it gives us, regardless of the scenarios for which we originally intended the code.

Also note that CanMergeWithoutConflict() is also rather opinionated itself in what we assume the user will want. It does not activate finding renames (and offers the user no way to do so) so some acceptable merges will not work. It all depends on what the user is planing to do beyond calling this one method.

Regardless of whether we want to expose this option to users or hide it behind a very specific method, throwing when we've asked for the short-circuit on error seems wrong. In CanMergeWithoutConflict() we'd be converting a catch block into a boolean, which reeks of code-smell.

There is yet another reason why I don't want to make everyone go through CanMergeWithoutConflict(). It simply doesn't do what we want to do in the scenarios for which the short-circuit was created. It answers the question of whether you could merge, but it doesn't tell you what the result of a successful merge is. So I can't use it for the GitHub/VSTS/MyVeryOwnPRInterface use-case, since in order to take advantage of the quick negatives, I'd have to perform successful merges twice (which I'm just gonna go ahead and claim is the 80% case) twice, which would make this feature completely useless.

@ethomson
Copy link
Member

which would make this feature completely useless.

Exactly.

@carlosmn carlosmn changed the title Update to libgit2 a27f31d8 Update to libgit2 6aa06b6 Dec 15, 2015
ethomson pushed a commit that referenced this pull request Feb 22, 2016
@ethomson ethomson merged commit cf6a3c5 into vNext Feb 22, 2016
@carlosmn carlosmn deleted the cmn/lg2-update branch February 22, 2016 15:34
6405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0