diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 090f060e..ce47f589 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -516,20 +516,18 @@ namespace SourceGit private bool TryLaunchedAsAskpass(IClassicDesktopStyleApplicationLifetime desktop) { + var launchAsAskpass = Environment.GetEnvironmentVariable("SOURCEGIT_LAUNCH_AS_ASKPASS"); + if (launchAsAskpass is not "TRUE") + return false; + var args = desktop.Args; - if (args == null || args.Length != 1) - return false; + if (args.Length > 0) + { + desktop.MainWindow = new Views.Askpass(args[0]); + return true; + } - var param = args[0]; - if (Directory.Exists(param)) - return false; - - if (!param.StartsWith("enter passphrase", StringComparison.OrdinalIgnoreCase) && - !param.Contains(" password", StringComparison.OrdinalIgnoreCase)) - return false; - - desktop.MainWindow = new Views.Askpass(param); - return true; + return false; } private void TryLaunchedAsNormal(IClassicDesktopStyleApplicationLifetime desktop) diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index c30ba59b..ab493474 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -42,7 +42,7 @@ namespace SourceGit.Commands { var start = new ProcessStartInfo(); start.FileName = Native.OS.GitExecutable; - start.Arguments = "--no-pager -c core.quotepath=off "; + start.Arguments = "--no-pager -c core.quotepath=off -c credential.helper=manager "; start.UseShellExecute = false; start.CreateNoWindow = true; start.RedirectStandardOutput = true; @@ -56,17 +56,13 @@ namespace SourceGit.Commands start.Environment.Add("DISPLAY", "required"); start.Environment.Add("SSH_ASKPASS", selfExecFile); // Can not use parameter here, because it invoked by SSH with `exec` start.Environment.Add("SSH_ASKPASS_REQUIRE", "prefer"); + start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE"); // If an SSH private key was provided, sets the environment. if (!string.IsNullOrEmpty(SSHKey)) - { start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new -i '{SSHKey}'"); - } else - { start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new"); - start.Arguments += "-c credential.helper=manager "; - } // Force using en_US.UTF-8 locale to avoid GCM crash if (OperatingSystem.IsLinux())