-
-
Notifications
You must be signed in to change notification settings - Fork 339
New remotes save with unexpected metadata in the presence of global configuration #1951
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
Comments
Apologies for the late response, thanks a lot for reporting and sorry for the hassle. I understand that After reloading, this is also what we see - global and local modifications were merged effectively, something that isn't happening when Git is performing the same operation.
I agree that a fix would be pass only the local To me, a fix would be a documentation change to make clear that the passed configuration isn't filtered, and is expected to be filtered based on the user needs. Typically, this config should only contain local sections, it kind of overrides everything that is present already anyway. As a second step, there could be a Do you think that would solve the problem decently? Maybe there are other solutions you imagined? |
Right. So when we actually write out configuration in Jujutsu, we do
I am not sure this would be a great or at least complete fix. It would mean that you can’t really use the higher-level My feeling is that a more holistic fix might look like: Or something like that; it’s just a sketch and there are trade‐offs here. Unfortunately I don’t think I’ll have time to do a restructuring this big any time soon :( The workaround will probably work fine for us and we can do a more complicated one if our remote management needs become more complex. |
I see, thanks for pointing this out! The
I also think something like this is needed, but only when writing files back is desired. There are legitimate cases when one wants to do in-memory edits, and this is (seemingly) fine with the current system. Without going into any detail, it feels like Finally, once
That is an interesting thought, and I admittedly don't understand how it would work, but we will get to it when we get to it :). |
Current behavior 😯
When a user has global configuration like
remote.origin.prune = true
, a repository configuration with no remote is opened, and a remote is created and saved with that name to the repository’s configuration, the new configuration is written to the existing section from the global configuration. This means that the metadata from the global configuration (including trust) is used instead of the file’s metadata, and an attempt to save the modified configuration withconfig.write_to_filter(&mut config_file, |section| section.meta() == config.meta())
will omit the new remote.This differs from the behaviour when there is no configuration for that remote outside of the repository configuration file, or the behaviour where a separate remote section already exiets in the repository configuration.
Expected behavior 🤔
A new remote section is created if it does not already exist in the
gix::config::File
, even if there is configuration for that remote from other sources.In general I’m not sure when you would ever want the behaviour of the current
section_mut
family of functions, and I suspect this is downstream of the fact thatgix::config::File
mixes together sections from all sources, which also makes editing and saving configuration somewhat inconvenient. I think it is likely that a better design would have agix::config::File
per configuration source, with an abstraction on top that layers them together for look‐up of values. Mutating an abstraction consisting of the combination of multiple cascading configurations doesn’t make that much sense; you want to use it to decide the effective values, but operate on one specific file for mutation and writing.However, this could be worked around in the remote API by simply creating a new section if one with metadata that matches the actual file doesn’t already exist.
Git behavior
Steps to reproduce 🕹
Output:
The text was updated successfully, but these errors were encountered: