Skip to content

Conversation

cwstra
Copy link
Contributor

@cwstra cwstra commented Apr 20, 2022

What's the problem this PR addresses?
At present, berry does not respect the GIT_SSH_COMMAND or GIT_SSH environment variables, nor the .gitignore file's core.sshCommand setting. In the original issue, this prevented a user from using plink instead of ssh, and I found the issue when I tried (and failed) to override which ssh command I wished to use on windows.

(Partially) Resolves #3271.
...

How did you fix it?
git's behavior around the two environment variables is as follows:

  • If GIT_SSH_COMMAND is set, treat that variable as a full command (including flags) to be run in place of ssh
  • Otherwise, if GIT_SSH is set, treat that variable as the path to the executable to use in place of ssh. It is not expected to include flags.

As such, the straightforward fix for berry seems to be:

  • If GIT_SSH_COMMAND is set, use that in place of the existing command.
  • Otherwise, if GIT_SSH is set, replace the ssh in the existing command with the value of GIT_SSH.

Checking the .gitignore file would be ideal, but more involved, and respecting the environment variables at least provides a method for the user to force their own command in place of the standard.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • (I went with patching everything that the cli suggested, which might have been a bit aggressive.)
  • I will check that all automated PR checks pass before the PR gets reviewed.

@cwstra cwstra changed the title Respect git ssh command Respect GIT_SSH_COMMAND Apr 20, 2022
@merceyz merceyz changed the title Respect GIT_SSH_COMMAND fix(git): respect GIT_SSH_COMMAND and GIT_SSH Apr 21, 2022
@arcanis arcanis merged commit d48cfed into yarnpkg:master Apr 25, 2022
@cwstra cwstra deleted the respect-git-ssh-command branch April 25, 2022 13:46
merceyz added a commit that referenced this pull request May 12, 2022
* Respect GIT_SSH(_COMMAND)

* Version bumps

* Backticks

* chore: versions

Co-authored-by: merceyz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Yarn overwriting SSH command used for Git
3 participants