mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
enhance: do NOT modify global .gitconfig if value equals git default (#465)
This commit is contained in:
parent
86c6254fb2
commit
676835dee5
1 changed files with 10 additions and 10 deletions
|
@ -128,16 +128,16 @@ namespace SourceGit.Views
|
||||||
protected override void OnClosing(WindowClosingEventArgs e)
|
protected override void OnClosing(WindowClosingEventArgs e)
|
||||||
{
|
{
|
||||||
var config = new Commands.Config(null).ListAll();
|
var config = new Commands.Config(null).ListAll();
|
||||||
SetIfChanged(config, "user.name", DefaultUser);
|
SetIfChanged(config, "user.name", DefaultUser, "");
|
||||||
SetIfChanged(config, "user.email", DefaultEmail);
|
SetIfChanged(config, "user.email", DefaultEmail, "");
|
||||||
SetIfChanged(config, "user.signingkey", GPGUserKey);
|
SetIfChanged(config, "user.signingkey", GPGUserKey, "");
|
||||||
SetIfChanged(config, "core.autocrlf", CRLFMode != null ? CRLFMode.Value : null);
|
SetIfChanged(config, "core.autocrlf", CRLFMode != null ? CRLFMode.Value : null, null);
|
||||||
SetIfChanged(config, "commit.gpgsign", EnableGPGCommitSigning ? "true" : "false");
|
SetIfChanged(config, "commit.gpgsign", EnableGPGCommitSigning ? "true" : "false", "false");
|
||||||
SetIfChanged(config, "tag.gpgsign", EnableGPGTagSigning ? "true" : "false");
|
SetIfChanged(config, "tag.gpgsign", EnableGPGTagSigning ? "true" : "false", "false");
|
||||||
SetIfChanged(config, "gpg.format", GPGFormat.Value);
|
SetIfChanged(config, "gpg.format", GPGFormat.Value, "opengpg");
|
||||||
|
|
||||||
if (!GPGFormat.Value.Equals("ssh", StringComparison.Ordinal))
|
if (!GPGFormat.Value.Equals("ssh", StringComparison.Ordinal))
|
||||||
SetIfChanged(config, $"gpg.{GPGFormat.Value}.program", GPGExecutableFile);
|
SetIfChanged(config, $"gpg.{GPGFormat.Value}.program", GPGExecutableFile, "");
|
||||||
|
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
|
@ -244,12 +244,12 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetIfChanged(Dictionary<string, string> cached, string key, string value)
|
private void SetIfChanged(Dictionary<string, string> cached, string key, string value, string defValue)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
if (cached.TryGetValue(key, out var old))
|
if (cached.TryGetValue(key, out var old))
|
||||||
changed = old != value;
|
changed = old != value;
|
||||||
else if (!string.IsNullOrEmpty(value))
|
else if (!string.IsNullOrEmpty(value) && value != defValue)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
|
|
Loading…
Reference in a new issue