-
Notifications
You must be signed in to change notification settings - Fork 910
Enumerate refspecs #553
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
Enumerate refspecs #553
Conversation
This is wrong. With
It does. Unless I'm missing some functions, this forces you to store every refspec in the configuration. This is bad, as it stops you from using a specific refspec for one fetch. |
Ah, now I see.
I think both methods (saving or temporary editing) would be useful. I guess we could simply omit the I see one issue: We would have to keep the
I missed that one. But it is not implemented in libgit2sharp yet, is it? |
Yes, we should provide the user a way to explicitly save the current configuration, but there are many situations where you want to modify the refspecs or other attributes only in-memory. The issues with something like You'd release the I don't know whether mutlivars are exposed in libgit2sharp. They're a right PITA either way. Btw, with libgit2/libgit2#1914 I'm hoping to move away from this kind of direct modification and simply provide a way to set the refspecs you want (with |
That's my opinion as well, and just as it happens, it is currently implemented that way. Maybe we should get rid of the
|
Current convention is that 1) a new instance is always returned, and 2) that instance should be immutable. See use of |
If we actually use the
and then have three remotes, where But as I see, this is not possible to implement with the current libgit2 api, because there is no way to clone a remote that does not exist in the config file. We can only derive remotes from actual config remotes. (even if we did not provide the Maybe we should provide |
@Yogu I'd prefer to not cope with mutable objects. As we all make take some time to reach to an agreement regarding the design of the API to update the refspecs, how about reducing the scope of this PR? Ideally this PR would focus on the much more consensual reading aspects (loading, enumerator, indexer, ...) and could be merged reasonably quickly. Then, once this is merged, a new one would be submitted to bring back the updating features on the table. |
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.
Please use Ensure
to guard against potential invalid parameters
@Yogu Thanks a lot for this proposal. I quite like what I read! |
I will remove the modifying aspects of this pull requests, but I want to get this issue written down: My implementation is currently inconsistent regarding the use of the
Or, if you really like to,
where Having a way to parse refspecs, we could also construct @carlosmn: Are there plans to provide parse/create refspec API methods? If not, should we implement it in libgit2sharp? Alternatively to all this, we could stay with |
I'm on the fence on exposing The enumeration is useful for refspecs that have been dwim'ed already, as a bunch of them won't be able to match anything after you've connected to the remote. When used in git-core, these refspecs are either used in a connected remote or a fully-specified one. The way I envision the refspec setting/update function is of the |
LibGit2Sharp.Tests/RefSpecFixture.cs
Outdated
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.
Aren't we missing something like this here?
Assert.Equal(1, count);
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.
Oh right, I forgot about than one when I removed the Count
property.
@Yogu The PR doesn't appear to merge cleanly. Can you rebase it on top of vNext, please? |
The Remote.RefSpecs property allows to enumerate over all refspecs defined for a specific remote.
Rebased without conflicts. Looks fine, the tests still pass. |
🎉 Thanks! |
The Remote.RefSpecs property allows to enumerate over all refspecs defined for a specific remote.
The intention of this extension actually is to fetch git notes. As libgit2 does not allow to fetch a specified refspec, you have to add it to the configuration. But libgit2 does not supportconfig --add
either, so I decided to choose the proper way.This pull request has been shrunken to only include read access. Write access will be discussed and implementet later (see this branch for the version containing updating features discussed here).
What do you think of it? I am eager for any feedback / suggestions.