-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Setup
- Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.37.0.windows.1
cpu: x86_64
built from commit: 989c3a6832b035f6124b0a23da9c0f8f18afa550
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
- Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.19044.1766]
- What options did you set as part of the installation? Or did you choose the
defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
- Any other interesting things about your environment that might be related
to the issue you're seeing?
Details
- Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
None - calling directly from Win-R run prompt (so, legacy cmd terminal).
- What commands did you run to trigger this issue? If you can provide a
Minimal, Complete, and Verifiable example
this will help us understand the issue.
#PREP:
mkdir -p /c/ssh-test
cat > /c/ssh-test/ssh-test-wrapper << "EOF"
#!/bin/bash
ssh-agent >| /dev/null
exec ssh "$@"
EOF
setx 'GIT_SSH_COMMAND' 'C:/ssh-test/ssh-test-wrapper'
#EXECUTION
Win-R: git clone [email protected]:whatever
OR: open a cmd terminal, run the same thing, type "exit"
- What did you expect to occur after running these commands?
Git to run, with success or error, and exit when done, leaving any ssh-agent processes that were spawned still running.
- What actually happened instead?
The legacy cmd console window remains open, after the process has exited, until closed manually, or until the ssh-agent process spawned within the git wrapper is killed. Closing the terminal also closes the ssh-agent.
Interestingly, if SSH was called several times (because of a connection error/retry?), then one of the ssh-agents disconnects correctly/successfully, and one gets "stuck" to the terminal process.
- If the problem was occurring with a specific repository, can you provide the
URL to that repository to help us with testing?
No - this isn't necessarily a bug per se, what I'm doing is clearly not "expected". I'm just very perplexed by this behavior.
If the "ssh-agent" line in the wrapper file is commented out, then the behavior is the same as without the wrapper at all (console closes / completes normally).
If git is called from within a "Git Bash" shell (regardless of the terminal), or even a Cmd shell in another terminal like "Windows Terminal", then it completes normally (regardless of whether the wrapper calls "ssh-agent" or not).
In case it's not obvious, I'm trying to set things up so that an ssh-agent starts up correctly, just-in-time, even when git is called outside of git bash, eg in a GUI. My real script is obviously much more complicated/interesting than the above, but the above illustrates the perplexing "if an ssh-agent process is spawned in git, when not in the context of a bash shell, and in a windows console, then the git process does not complete until the ssh-agent process is terminated" behavior.