-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(git config settings pages): Add system-wide settings #12185
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
😍 |
me included Do you have a clue why this PR makes "your" testcase |
The name of the test made me think that it was a flaky test so I relaunched the build. I didn't remembered I wrote the test and had not looked at the possible reason. |
9d20c5a
to
4814663
Compare
8544e32
to
5d6fac6
Compare
src/app/GitCommands/Git/GitModule.cs
Outdated
public string? GetGitSetting(string setting, string scopeArg, bool cache = false) | ||
{ | ||
GitArgumentBuilder args = new("config") { "--includes", scopeArg, "--get", setting }; | ||
GitArgumentBuilder args = new("config") { "get", scopeArg, "--includes", setting }; |
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.
GitArgumentBuilder args = new("config") { "get", scopeArg, "--includes", setting }; | |
GitArgumentBuilder args = new("config") { "--get", scopeArg, "--includes", setting }; |
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.
Sorry, I was not aware of this git command line change in v2.46
I had to update my git version otherwise got exceptions. So this PR won't work with <v2.46...
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.
Good to have this caught before merging!
5948041
to
5d6fac6
Compare
I don't know if the behavior was like that before but now, when switching between git config "setting source", changes are saved immediately (without clicking 'Apply'). |
5d6fac6
to
df542cc
Compare
Yes, this behavior has changed. |
df542cc
to
3e22e0e
Compare
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.
🚀
src/app/GitCommands/Git/GitModule.cs
Outdated
@@ -316,11 +317,15 @@ public IConfigFileSettings LocalConfigFile | |||
// 4) branch, tag name, errors, warnings, hints encoded in system default encoding | |||
public static readonly Encoding LosslessEncoding = Encoding.GetEncoding("ISO-8859-1"); // is any better? | |||
|
|||
public Encoding FilesEncoding => ((ConfigFileSettings)EffectiveConfigFile).FilesEncoding ?? new UTF8Encoding(false); | |||
private Encoding? _defaultEncoding; |
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.
[nit] move to the top
src/app/GitCommands/Git/GitModule.cs
Outdated
public Encoding FilesEncoding => ((ConfigFileSettings)EffectiveConfigFile).FilesEncoding ?? new UTF8Encoding(false); | ||
private Encoding? _defaultEncoding; | ||
|
||
private Encoding DefaultEncoding => _defaultEncoding ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); |
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.
Why is the field needed? Why not init the property straight away? Why not make it static?
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.
👍
Yes, lazy instantiation is not worth it.
namespace GitCommands.Settings; | ||
|
||
[DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] | ||
public sealed class EffectiveGitConfigSettings(IExecutable gitExecutable) : GitConfigSettingsBase(gitExecutable, GitSettingLevel.Effective), IConfigValueStore |
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.
Does this and the rest of the hierarchy need to be public?
Would be great to have some xml-docs for the types and public members
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.
public
because used by GUI project.
I have added xml-docs to classes and to protected
stuff.
Public methods are interface implementations and inherit the xml-docs.
|
||
protected override void Update() => Update(Clear, StoreSetting); | ||
|
||
private void Clear() |
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.
[nit] Keeping methods in alphabetical order helps navigating the code.
{ | ||
if (gitSettingLevel == GitSettingLevel.Effective) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(gitSettingLevel), $"Use read-only {nameof(EffectiveGitConfigSettings)} instance instead."); |
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.
ArgumentOutOfRangeException
has a number of Throw* helpers, may worth using those.
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.
ArgumentOutOfRangeException
has a number of Throw* helpers, may worth using those.
already checked, not enough: it is unable to compare enum values
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.
These aren't flags, so compare as ints?
using GitExtensions.Extensibility.Settings; | ||
using Microsoft; | ||
|
||
namespace GitUI.CommandsDialogs.SettingsDialog |
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.
namespace GitUI.CommandsDialogs.SettingsDialog | |
namespace GitUI.CommandsDialogs.SettingsDialog; |
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.
Done. I had just renamed this class (in a sub-optimal way, but it is similar to GitConfigAdvancedSettingsPage
).
bool isSet = !string.IsNullOrEmpty(value); | ||
GitArgumentBuilder args = new("config") | ||
{ | ||
#if UseNewGitConfigSyntax2_46 |
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.
Is there a particular reason to not use GitVersion.Current
(i.e. creating a property GitVersion.Current.SupportNewGitConfigSyntax
) instead?
This does not work with WSL Some paths like editor and mergetool is expected to be in Windows format. In some way it is an improvement, but not working yet |
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.
WSL Git settings are messed up, not possible to e.g. merge in WSL
0ac781a
to
7ee491c
Compare
How to proceed with this PR (and the follow up)? Some issues I see, no full investigation.
|
I have already changed it to always use the native - i.e. Windows - git for getting & setting git config. We could add another selection to these two git settings pages which switches between native git and WSL git. |
You still get an exception in WSL just switching to local view. GitExtensions.Extensibility.ExternalOperationException Source=GitExtensions.Extensibility Inner Exception 1: |
This was nonsense because git config settings must be set in WSL. Reverted.
not really necessary:
should be done in a follow-up
We should always use WSL commands. Then only WSL git config settings apply. And these are shown and controlled in the settings pages. |
and use it in GitConfigSettingsSet Refs: gitextensions#12185
and enable ThreeState for all settings checkboxes Refs: gitextensions#12185
6045a84
to
15c1383
Compare
Both ways to start a merge tool work well with this PR (with both suggestions adapting to WSL). |
and remove its non-null replacement ConfigFileSettings.GetValue and remove redundant, hardly used IConfigFileSettings.GetString Refs: gitextensions#12185
from IConfigFileSettings Move implementation of GetValue<T> to ISettingsValueGetter Move implementation of SetPathValue to PathSetting.ConvertPathToGitSetting SettingsSource.SettingLevel must not be modified Refs: gitextensions#12185
and IGitModule.GetEffectiveSettingsByPath and SettingsSource.Get/SetNullableEnum Refs: gitextensions#12185
and to GitConfigBaseSettingsPage Refs: gitextensions#12185
from ConfigFileSettings Refs: gitextensions#12185
and use it in GitConfigSettingsSet Refs: gitextensions#12185
and enable ThreeState for all settings checkboxes Refs: gitextensions#12185
b61926a
to
f3e694d
Compare
only in some situations, but now I lost where I got it |
Fixes #10914
Fixes #11764
Proposed changes
git config list
in order to correctly display effective settingsIPersistentConfigValueStore
fromIConfigFileSettings
SettingsSourceExtension.ByPath
GitConfigSettingsSet
and toGitConfigBaseSettingsPage
GitConfig/DistributedSettingsSet.Save
GitEncodingSettings
fromConfigFileSettings
Review commit by commit is recommended.
Screenshots
Before
After
Test methodology
Please do not squash merge
✒️ I contribute this code under The Developer Certificate of Origin.