diff --git a/src/Commands/Clone.cs b/src/Commands/Clone.cs
index d1542a4c..fefc0f3e 100644
--- a/src/Commands/Clone.cs
+++ b/src/Commands/Clone.cs
@@ -15,9 +15,8 @@ namespace SourceGit.Commands {
handler = outputHandler;
onError = errHandler;
- if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ if (string.IsNullOrEmpty(sshKey)) {
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs
index 6e0d1dd5..f0ff0d72 100644
--- a/src/Commands/Command.cs
+++ b/src/Commands/Command.cs
@@ -52,11 +52,6 @@ namespace SourceGit.Commands {
///
public bool TraitErrorAsOutput { get; set; } = false;
- ///
- /// 用于设置该进程独有的环境变量
- ///
- public Dictionary Envs { get; set; } = new Dictionary();
-
///
/// 运行
///
@@ -73,8 +68,6 @@ namespace SourceGit.Commands {
if (!string.IsNullOrEmpty(Cwd)) start.WorkingDirectory = Cwd;
- foreach (var kv in Envs) start.EnvironmentVariables[kv.Key] = kv.Value;
-
var progressFilter = new Regex(@"\s\d+%\s");
var errs = new List();
var proc = new Process() { StartInfo = start };
diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs
index 49359462..ad3925cc 100644
--- a/src/Commands/Fetch.cs
+++ b/src/Commands/Fetch.cs
@@ -16,8 +16,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
@@ -35,8 +34,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
diff --git a/src/Commands/Pull.cs b/src/Commands/Pull.cs
index eb3b4f4c..83b27dc4 100644
--- a/src/Commands/Pull.cs
+++ b/src/Commands/Pull.cs
@@ -17,8 +17,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
diff --git a/src/Commands/Push.cs b/src/Commands/Push.cs
index c2faed97..7784c581 100644
--- a/src/Commands/Push.cs
+++ b/src/Commands/Push.cs
@@ -14,8 +14,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
@@ -34,8 +33,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
@@ -48,8 +46,7 @@ namespace SourceGit.Commands {
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
if (!string.IsNullOrEmpty(sshKey)) {
- Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
- Args = "";
+ Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
} else {
Args = "-c credential.helper=manager ";
}
diff --git a/src/Views/Popups/Remote.xaml.cs b/src/Views/Popups/Remote.xaml.cs
index deb09322..24a2762d 100644
--- a/src/Views/Popups/Remote.xaml.cs
+++ b/src/Views/Popups/Remote.xaml.cs
@@ -52,13 +52,16 @@ namespace SourceGit.Views.Popups {
return Task.Run(() => {
Models.Watcher.SetEnabled(repo.Path, false);
+
+ if (string.IsNullOrEmpty(sshKey)) {
+ new Commands.Config(repo.Path).Set($"remote.{RemoteName}.sshkey", null);
+ } else {
+ new Commands.Config(repo.Path).Set($"remote.{RemoteName}.sshkey", sshKey);
+ }
+
if (remote == null) {
var succ = new Commands.Remote(repo.Path).Add(RemoteName, RemoteURL);
if (succ) new Commands.Fetch(repo.Path, RemoteName, true, UpdateProgress).Exec();
-
- if (!string.IsNullOrEmpty(sshKey)) {
- new Commands.Config(repo.Path).Set($"remote.{RemoteName}.sshkey", sshKey);
- }
} else {
if (remote.URL != RemoteURL) {
var succ = new Commands.Remote(repo.Path).SetURL(remote.Name, RemoteURL);
@@ -69,11 +72,8 @@ namespace SourceGit.Views.Popups {
var succ = new Commands.Remote(repo.Path).Rename(remote.Name, RemoteName);
if (succ) remote.Name = RemoteName;
}
-
- if (!string.IsNullOrEmpty(sshKey)) {
- new Commands.Config(repo.Path).Set($"remote.{RemoteName}.sshkey", sshKey);
- }
}
+
Models.Watcher.SetEnabled(repo.Path, true);
return true;
});