From cc6e4866639d500e1c1bec3675fca783d60c01e6 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 13 Sep 2024 15:20:52 +0800 Subject: [PATCH] enhance: do NOT modify repository's local configuration if it is equals to default value --- src/ViewModels/RepositoryConfigure.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index b72345ee..8ddf84a5 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -138,22 +138,22 @@ namespace SourceGit.ViewModels public void Save() { - SetIfChanged("user.name", UserName); - SetIfChanged("user.email", UserEmail); - SetIfChanged("commit.gpgsign", GPGCommitSigningEnabled ? "true" : "false"); - SetIfChanged("tag.gpgsign", GPGTagSigningEnabled ? "true" : "false"); - SetIfChanged("user.signingkey", GPGUserSigningKey); - SetIfChanged("http.proxy", HttpProxy); + SetIfChanged("user.name", UserName, ""); + SetIfChanged("user.email", UserEmail, ""); + SetIfChanged("commit.gpgsign", GPGCommitSigningEnabled ? "true" : "false", "false"); + SetIfChanged("tag.gpgsign", GPGTagSigningEnabled ? "true" : "false", "false"); + SetIfChanged("user.signingkey", GPGUserSigningKey, ""); + SetIfChanged("http.proxy", HttpProxy, ""); } - private void SetIfChanged(string key, string value) + private void SetIfChanged(string key, string value, string defValue) { bool changed = false; if (_cached.TryGetValue(key, out var old)) { changed = old != value; } - else if (!string.IsNullOrEmpty(value)) + else if (!string.IsNullOrEmpty(value) && value != defValue) { changed = true; }