Skip to content

fix(gitbutler-git): avoid tampering with existing SSH configuration#13251

Open
slarse wants to merge 3 commits intomasterfrom
GB-1286/avoid-overriding-user-config
Open

fix(gitbutler-git): avoid tampering with existing SSH configuration#13251
slarse wants to merge 3 commits intomasterfrom
GB-1286/avoid-overriding-user-config

Conversation

@slarse
Copy link
Copy Markdown
Contributor

@slarse slarse commented Apr 10, 2026

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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Apr 10, 2026 8:23am

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Apr 10, 2026
@slarse slarse requested a review from Byron April 10, 2026 06:47
@slarse slarse force-pushed the GB-1286/avoid-overriding-user-config branch from c8a7c34 to 7e29d4e Compare April 10, 2026 07:40
@slarse slarse marked this pull request as ready for review April 10, 2026 07:44
Copilot AI review requested due to automatic review settings April 10, 2026 07:44
@slarse
Copy link
Copy Markdown
Contributor Author

slarse commented Apr 10, 2026

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_SSH to GIT_SSH_COMMAND and stop appending OpenSSH-only options to existing SSH configurations.
  • Add ensure_git_ssh_is_configured to conservatively set GIT_SSH/GIT_SSH_COMMAND only when needed.
  • Refactor the internal execution helpers to always build an env map and pass it through askpass/direct execution.

slarse added 2 commits April 10, 2026 10:17
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.
@slarse slarse force-pushed the GB-1286/avoid-overriding-user-config branch from 724e61d to b155530 Compare April 10, 2026 08:18
Copilot AI review requested due to automatic review settings April 10, 2026 08:18
@slarse slarse force-pushed the GB-1286/avoid-overriding-user-config branch from b155530 to 5010e03 Compare April 10, 2026 08:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to fetch (from private GitHub remotes, git/SSH protocol)

2 participants