-
Notifications
You must be signed in to change notification settings - Fork 899
Add unmatched pathspecs options #343
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
/cc @jamill |
As a bonus, the build is now π For
I have the feeling I'm missing some other edge cases though, but can't figure out which ones... |
@@ -253,7 +253,7 @@ public static Signature git_commit_committer(GitObjectSafeHandle obj) | |||
{ | |||
using (ThreadAffinity()) | |||
using (var treePtr = new ObjectSafeWrapper(tree.Id, repo)) | |||
using (var parentObjectPtrs = new DisposableEnumerable<ObjectSafeWrapper>(parentIds.Select(id => new ObjectSafeWrapper(id, repo)))) | |||
using (var parentObjectPtrs = new DisposableEnumerable<ObjectSafeWrapper>(parentIds.Select(id => new ObjectSafeWrapper(id, repo)).ToArray())) |
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.
Using ToList()
here would avoid an extra array allocation for the final result.
Based on usage of parentObjectPtrs.Count()
below, should DisposableEnumerable
be converted to DisposableCollection
to avoid an extra enumeration?
Latest changes:
|
π |
@yorah I cherry picked the first five commits and pushed them into
I'm in favor of this approach. And the code looks pretty clean. However, as this is quite a breaking change, I'd like to wait for some days to see if the other contributors have anything to say about this. |
Rebased and running. As a bonus, I will also add some test coverage related to accepting globs as pathspecs for staging/unstaging. In the next few days. |
Added some tests related to accepting globs as pathspecs. Passing "*" is currently broken, waiting for feedback on libgit2/libgit2#1367. Does anyone have an opinion related to the change of behaviour (strict vs lax)? Please? π± |
Proposal as of now (current code) Only throw/notify for explicit paths (renamed the Advantages I see:
@dahlbyk regarding the proposal you made in libgit2/libgit2#1367, I think checking if offending pathspecs match any of the already found files in libgit2sharp is not easily feasible. This would mean either exposing the _fnmatch functionality implemented in libgit2 (which doesn't feel right), or re-implementing our own fnmatch. We would also have to take the RFC Before going further, I would like to make a request for comments. Basically, the initial question this PR tries to address boils down to: I think there are two main cases:
So the question can also be reformulated as: |
@nulltoken would it be possible to cherry-pick 144ac99 and 5675ea0 so it's easier to read the core PR?
I'll defer to people that are actually building clients that need to Stage/Unstage. |
@dahlbyk Done! |
@yorah Could you please rebase this PR on top of vNext? |
*/ | ||
[Theory] | ||
[InlineData("*u*", 0)] | ||
//[InlineData("*", 0)] TODO: waiting for https://github.com/libgit2/libgit2/pull/1367 |
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.
What's the current status of this?
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.
Working with my latest proposal, uncommenting.
All the overloads can now report and/or fail upon unmatched explicit paths. By default, the passed list of paths will be treated as a list of pathspecs. When an ExplicitPathsOptions is passed to the overloads, this list of paths will be treated as explicit paths. In that case, the default behavior is to throw when one of this explicit path is unmatched.
π Merged |
Cool! @dahlbyk I think this impacts your submodule PR (for the |
This is related to #274
Points of attention:
Remove()
is not included in this PR.