diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index c13e4bf7..11a25b36 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -153,7 +153,6 @@ namespace SourceGit.Commands { var start = new ProcessStartInfo(); start.FileName = Native.OS.GitExecutable; - start.Arguments = "--no-pager -c core.quotepath=off -c credential.helper=manager "; start.UseShellExecute = false; start.CreateNoWindow = true; @@ -182,16 +181,27 @@ namespace SourceGit.Commands start.Environment.Add("LC_ALL", "C"); } - // Force using this app as git editor. - start.Arguments += Editor switch - { - EditorType.CoreEditor => $"""-c core.editor="\"{selfExecFile}\" --core-editor" """, - EditorType.RebaseEditor => $"""-c core.editor="\"{selfExecFile}\" --rebase-message-editor" -c sequence.editor="\"{selfExecFile}\" --rebase-todo-editor" -c rebase.abbreviateCommands=true """, - _ => "-c core.editor=true ", - }; + var builder = new StringBuilder(); + builder + .Append("--no-pager -c core.quotepath=off -c credential.helper=") + .Append(Native.OS.CredentialHelper) + .Append(' '); - // Append command args - start.Arguments += Args; + switch (Editor) + { + case EditorType.CoreEditor: + builder.Append($"""-c core.editor="\"{selfExecFile}\" --core-editor" """); + break; + case EditorType.RebaseEditor: + builder.Append($"""-c core.editor="\"{selfExecFile}\" --rebase-message-editor" -c sequence.editor="\"{selfExecFile}\" --rebase-todo-editor" -c rebase.abbreviateCommands=true """); + break; + default: + builder.Append("-c core.editor=true "); + break; + } + + builder.Append(Args); + start.Arguments = builder.ToString(); // Working directory if (!string.IsNullOrEmpty(WorkingDirectory)) diff --git a/src/Native/OS.cs b/src/Native/OS.cs index 27fce1c3..df72aff8 100644 --- a/src/Native/OS.cs +++ b/src/Native/OS.cs @@ -58,6 +58,12 @@ namespace SourceGit.Native private set; } = new Version(0, 0, 0); + public static string CredentialHelper + { + get; + set; + } = "manager"; + public static string ShellOrTerminal { get; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 028c7643..6c57b7c6 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -555,6 +555,7 @@ Git (>= 2.25.1) is required by this app Install Path Enable HTTP SSL Verify + Use git-credential-libsecret instead of git-credential-manager User Name Global git user name Git version diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 2281da5c..465a432d 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -559,6 +559,7 @@ 本软件要求GIT最低版本为2.25.1 安装路径 启用HTTP SSL验证 + 使用 git-credential-libsecret 替代 git-credential-manager 用户名 默认GIT用户名 Git 版本 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 72fda3ec..fcf3b399 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -559,6 +559,7 @@ 本軟體要求 Git 最低版本為 2.25.1 安裝路徑 啟用 HTTP SSL 驗證 + 使用 git-credential-libsecret 取代 git-credential-manager 使用者名稱 預設 Git 使用者名稱 Git 版本 diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs index 8e5f24c5..05be0601 100644 --- a/src/ViewModels/Preferences.cs +++ b/src/ViewModels/Preferences.cs @@ -310,6 +310,20 @@ namespace SourceGit.ViewModels set => SetProperty(ref _gitDefaultCloneDir, value); } + public bool UseLibsecretInsteadOfGCM + { + get => Native.OS.CredentialHelper.Equals("libsecret", StringComparison.Ordinal); + set + { + var helper = value ? "libsecret" : "manager"; + if (OperatingSystem.IsLinux() && !Native.OS.CredentialHelper.Equals(helper, StringComparison.Ordinal)) + { + Native.OS.CredentialHelper = helper; + OnPropertyChanged(); + } + } + } + public int ShellOrTerminal { get => _shellOrTerminal; diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml index bf5c2902..39055dfe 100644 --- a/src/Views/Preferences.axaml +++ b/src/Views/Preferences.axaml @@ -279,7 +279,7 @@ - + + +