fix(gitbutler-git): avoid tampering with existing SSH configuration#13251
Open
fix(gitbutler-git): avoid tampering with existing SSH configuration#13251
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
c8a7c34 to
7e29d4e
Compare
Contributor
Author
|
@Byron Please weigh in on this approach. I think it's better to respect user settings than to attempt to "augment" them, but there may be historical reasons for how this has worked that I'm not aware of. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates gitbutler-git’s Git CLI execution harness to avoid overriding user-provided SSH configuration (env vars or core.sshCommand) and only apply GitButler’s OpenSSH defaults when no SSH behavior is configured.
Changes:
- Stop unconditionally promoting
GIT_SSHtoGIT_SSH_COMMANDand stop appending OpenSSH-only options to existing SSH configurations. - Add
ensure_git_ssh_is_configuredto conservatively setGIT_SSH/GIT_SSH_COMMANDonly when needed. - Refactor the internal execution helpers to always build an env map and pass it through askpass/direct execution.
Historically, we have unconditionally 1) promoted GIT_SSH to GIT_SSH_COMMAND, and 2) appended OpenSSH-specific options to the command. The GIT_SSH->GIT_SSH_COMMAND promotion caused issues with escaping of GIT_SSH, as GIT_SSH is explicitly a _program_ (path or just a name to be looked up on PATH), while GIT_SSH_COMMAND is an arbitrary shell command. So, for example, unescaped whitespace in GIT_SSH is fine but causes GIT_SSH_COMMAND to break. The appending of OpenSSH-specific options causes alternative clients (such as plink.exe on Windows) to break. To resolve these issues, we take a more conservative approach and only apply our own preferred defaults for OpenSSH if we cannot find any configuration for the SSH behavior in the current environment.
…_COMMAND It was unused and needlessly convoluted resolution order.
724e61d to
b155530
Compare
b155530 to
5010e03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Historically, we have unconditionally 1) promoted GIT_SSH to GIT_SSH_COMMAND, and 2) appended OpenSSH-specific options to the command.
The GIT_SSH->GIT_SSH_COMMAND promotion caused issues with escaping of GIT_SSH, as GIT_SSH is explicitly a program (path or just a name to be looked up on PATH), while GIT_SSH_COMMAND is an arbitrary shell command. So, for example, unescaped whitespace in GIT_SSH is fine but causes GIT_SSH_COMMAND to break.
The appending of OpenSSH-specific options causes alternative clients (such as plink.exe on Windows) to break.
To resolve these issues, we take a more conservative approach and only apply our own preferred defaults for OpenSSH if we cannot find any configuration for the SSH behavior in the current environment.
Replaces #13239
Fixes #13088