Skip to content

Forward Fork AskPass variables through WSL#156

Open
camjac251 wants to merge 1 commit into
andy-5:developfrom
camjac251:fix/fork-askpass
Open

Forward Fork AskPass variables through WSL#156
camjac251 wants to merge 1 commit into
andy-5:developfrom
camjac251:fix/fork-askpass

Conversation

@camjac251

Copy link
Copy Markdown

Summary

  • Forward Fork's credential-prompt environment into WSL when wslgit is
    invoked by Fork.
  • Apply WSL path translation only to variables containing Windows paths.
  • Preserve unrelated WSLENV entries while normalizing existing entries
    for the forwarded variables.

Problem

Fork can invoke wslgit with an AskPass executable configured while wslgit
runs Git inside WSL. Existing Windows process variables are not imported by
WSL unless they are registered in WSLENV, and Windows path values also need
WSL's /p translation flag.

As a result, Git and its credential-prompt process cannot reliably consume
Fork's existing AskPass and repository context inside WSL.

Implementation

Forward only this allowlist when FORK_PROCESS_ID indicates that wslgit was
started by Fork:

  • FORK_PROCESS_ID
  • SSH_ASKPASS_REQUIRE
  • NO_PROMPT
  • FORK_REPOSITORY_PATH
  • SSH_ASKPASS

FORK_REPOSITORY_PATH and SSH_ASKPASS are registered with the WSLENV
/p flag because they contain Windows paths. The other three variables are
forwarded without path translation.

Only variables already present in the process environment are registered.
Existing entries for the same key are matched case-insensitively and
normalized to one entry with the required flags. Unrelated WSLENV entries
remain in their original order.

Verification

  • cargo fmt --all -- --check
  • git diff --check develop...HEAD
  • Focused AskPass integration test: 1 passed, 0 failed.
  • Focused WSLENV normalization unit test: 1 passed, 0 failed.
  • Windows-target suite excluding the environment-specific upstream
    shell_environment_variable test: 32 passed, 0 failed, 1 filtered.
  • Gitleaks history scan: no leaks found.
  • Exercise Fork's real credential dialog through wslgit.

The excluded upstream test expects the inherited SHELL value to contain
/bin/bash; this environment supplies /usr/bin/zsh. The test is unchanged
and fails on this branch for that reason. Strict Clippy is also blocked by 28
warnings in unchanged upstream lines; the new lines were not among the
reported locations.

Compatibility

  • Invocations outside Fork are unchanged.
  • Missing Fork variables are not added to WSLENV.
  • No arbitrary process variables are forwarded.
  • Existing unrelated WSLENV entries are preserved.
  • This does not modify Fork's executable, Git credential-helper
    configuration, or the AskPass executable itself.

Related issues

Related to #151.

That report also contains an invalid-handle error and WSL startup diagnostics.
This change only addresses Fork credential-prompt environment forwarding and
does not claim to resolve those separate failure modes.

Share Fork's credential-prompt variables only when Fork is active.
Mark Windows path values with WSLENV /p translation and normalize
existing entries to avoid duplicate or conflicting flags.
@camjac251
camjac251 marked this pull request as ready for review July 17, 2026 22:09
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.

1 participant