From 99021d4e4f24c96693e556eb697dd642fefbe94e Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Wed, 26 Aug 2015 12:11:34 +0100 Subject: [PATCH 1/3] Handle multiple pageant processes --- GitUtils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 999233b04..0d90ddd6b 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -244,7 +244,7 @@ function Set-TempEnv($key, $value) { # is a running agent. function Get-SshAgent() { if ($env:GIT_SSH -imatch 'plink') { - $pageantPid = Get-Process | Where-Object { $_.Name -eq 'pageant' } | Select -ExpandProperty Id + $pageantPid = Get-Process | Where-Object { $_.Name -eq 'pageant' } | Select -ExpandProperty Id -First 1 if ($null -ne $pageantPid) { return $pageantPid } } else { $agentPid = $Env:SSH_AGENT_PID From f28bb54960f66215a9c11f5401f2b347c6910f8d Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Wed, 26 Aug 2015 12:13:55 +0100 Subject: [PATCH 2/3] Don't wait for pageant It's supposed to be a background service style process, so this otherwise waits indefinitely. Suspect this is true for other `$sshAgent`s too (see a few lines below) but have no test cases so haven't changed it. --- GitUtils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 0d90ddd6b..1e235f474 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -303,7 +303,7 @@ function Start-SshAgent([switch]$Quiet) { $pageant = Get-Command pageant -TotalCount 1 -Erroraction SilentlyContinue $pageant = if ($pageant) {$pageant} else {Guess-Pageant} if (!$pageant) { Write-Warning "Could not find Pageant."; return } - & $pageant + Start-Process -NoNewWindow $pageant } else { $sshAgent = Get-Command ssh-agent -TotalCount 1 -ErrorAction SilentlyContinue $sshAgent = if ($sshAgent) {$sshAgent} else {Guess-Ssh('ssh-agent')} From fe191a2124284be294790cc5b81ff2713c9e0844 Mon Sep 17 00:00:00 2001 From: GrahamTheCoder Date: Sat, 29 Aug 2015 14:29:51 +0100 Subject: [PATCH 3/3] Remove random extra space --- GitUtils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 1e235f474..92f84559c 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -303,7 +303,7 @@ function Start-SshAgent([switch]$Quiet) { $pageant = Get-Command pageant -TotalCount 1 -Erroraction SilentlyContinue $pageant = if ($pageant) {$pageant} else {Guess-Pageant} if (!$pageant) { Write-Warning "Could not find Pageant."; return } - Start-Process -NoNewWindow $pageant + Start-Process -NoNewWindow $pageant } else { $sshAgent = Get-Command ssh-agent -TotalCount 1 -ErrorAction SilentlyContinue $sshAgent = if ($sshAgent) {$sshAgent} else {Guess-Ssh('ssh-agent')}