-
Notifications
You must be signed in to change notification settings - Fork 899
The case for the removal of overloads which take an identity from the configuration #1173
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
👍 |
1 similar comment
👍 |
Transmuted this issue into a PR with a proposal. Thoughts? |
As a consumer of the API, completely removing the |
You're still free to assume that |
All I'm saying is that it's not very elegant. I understand why it's needed, but it also doesn't make for a very nice API. Perhaps a property added to the
I'm not a huge fan of that idea, because then Commit would have to check the property and throw an invalid operation exception if it was null. It makes assumptions about the state of the object that may not be true. Just thinking out loud about trying to find a more elegant solution. |
@ckuhn203 brings up a good point. Even if we would consider it a best practice to explicitly specify an author, a |
Beware of trying to implement the git tool's UI. It can change without much notice, and this bit specifically has done so a few times in the past as it's meant for humans, not code.
If there is absolutely nothing configured, git will continue and create a commit with whatever it can find out of the current machine name and user account, which is going to be the wrong thing more often than not, but it errs on the side of making progress which is presumably better for the first steps (it does also tell you how to set the configuration). This does however mean that many people end up wanting to do a filter-branch of the first commits because their name isn't right on there. What git does here is policy at the application layer, and what happens depends on it being a command-line application. If I were using a GUI without the user/email configuration set up, I would expect it to prompt me for the information. If I'm using some automation tool which performs a commit server-side, I would expect it to ask who to impersonate or use its name, as that information is much more useful than what system account it happens to run under. If it's a client-side automation tool, it's probably OK for it to use whatever is in the config, but I would expect it to be configurable. All of these decisions are down to what the tool does and in what context is runs. We cannot pretend to know what is right for the consumers of the library. I also don't feel particularly compelled to make it convenient not to care about what information goes into a rather visible part of immutable history data. It also goes against making the right thing easer than the wrong thing. You can still make it completely dependent on the configuration by passing the config-generated signature, but it's at least as easy to put in |
You've convinced me. We'll just need to update the wiki if/when this is implemented. I can see it causing a lot of confusion if it's not part of the Quick Start. |
Ah yes, we have one of those on this repo. Yes, the quick start would be a great place to say something like "the username from the config, or ask the user if you're committing on behalf of a user; if you're writing a tool, it's a good idea to identify it here so you know where the change came from". |
The case for the removal of overloads which take an identity from the configuration
👍 |
These are meant to make it convenient to use the configured signature when the programmer wants to take it from the configuration.
But this makes these overloads very dependent on the configuration, something which is almost guaranteed to change between the developer's machine and the production (or even test) usage.
This causes code which was seemingly working fine to stop working once deployed (and this kind of environment dependence has bit us in libgit2sharp's tests as well) and it's letting the programmer assume that the environment is set up correctly instead of letting them make sure that it is or take steps to set it up correctly. This is not helped by
BuildSignature()
returning a fake signature if none is available in the configuration.#1171 attempts to mitigate this problem by removing the fake signature. A programmer can now figure out whether the environment is set up correctly and set it up if that's the way they want to go (or conditionally provide their own signature). But it still lets the programmer make assumptions about the environment in which they are operating which can be confusing.
/cc @ckuhn203