-
Notifications
You must be signed in to change notification settings - Fork 899
Straighten api #210
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
Straighten api #210
Conversation
@dahlbyk Thanks a lot for the review! You may have commented directly in the commits rather than in the diff of the pull request. This explains why my answers are not gathered in this thread. The two comments below require some more specific explanation
From the standpoint of the LibGit2Sharp project, I see string based methods as "less" core. Turning them into extension methods has the side benefit to also push them farther in the intellisense context menu. The fact that some core methods delegate to an extension method is often the result of some effort in order to reduce the code duplication. I agree this is misleading and could benefit from some additional work :) I agree that some LibGit2Sharp string based extensions methods are very "thick" and bear far too much "logic" for a binding. When they're bug free and proved useful enough, I'll convert them into C code and open a PR against libgit2. |
I did indeed... sometimes it's harder to see in the overall diff how we got to where we ended up.
I rarely disagree with reducing code duplication, and certainly not here. I guess my disagreement would come from the blanket idea that using a string instead of an object necessarily makes it less deserving of a spot in the core API. If anything, I might argue the opposite - deleting/moving/etc by string is the more natural operation (after all, user input almost always comes in strings), and accepting a full object if we have one is a useful shortcut. |
I agree with this. I also like a clean history :)
Sorry, I wasn't very clear. I was not trying to be dogmatic. Far from it. Let me rephrase this in order to try to better express my intent: I'd prefer to drive the consumer toward using the GitObject and ObjectId based methods because they are more straightforward and, generally speaking, less "magic" than the string based methods. Some of those string based methods might even be too "magic" for the average user and more error prone (think Moreover, as they're a bit less straightforward (or a bit more complex), they might be a little bit less efficient than ObjectId based methods. In less words, I generally see LibGit2Sharp string based methods as:
Of course, I have no plan to deprecate them. However, I think they require some "above than average" knowledge to be properly used, though. |
Remove the final LF in each pkt line so ref names are stored correctly and split out the capabilities string explicitly, as C# doesn't stop at the first NUL. References libgit2#210
Recognize the error messages from the remote and throw an exception with the message if we receive an error. The code is messy, but a networ stream doesn't support peeking, so we need to read the first four bytes to see if they contain "ERR " and pass them to PktRef() if they don't, because we just removed part of the commit's hash from the stream. References libgit2#210
Having the knowledge in the Remote will allow us to use different transports more effectively and abstract away the details of the particular way of talking to the remote end. References libgit2#210
Pushing things left and right....