Skip to content

fix(git): inherit stdin for git fetch/pull so SSH auth works (#2211)#2215

Closed
artemgurzhii wants to merge 1 commit into
rtk-ai:developfrom
artemgurzhii:fix/2211-git-fetch-stdin
Closed

fix(git): inherit stdin for git fetch/pull so SSH auth works (#2211)#2215
artemgurzhii wants to merge 1 commit into
rtk-ai:developfrom
artemgurzhii:fix/2211-git-fetch-stdin

Conversation

@artemgurzhii

Copy link
Copy Markdown

Summary

  • Fixes git fetch falsely reported as access/repository error when it actually succeeds (exit 0) #2211: rtk git fetch/pull no longer fail with a false fatal: Could not read from remote repository error when the remote needs interactive auth.
  • Root cause: run_fetch/run_pull used exec_capture, which hardcodes stdin(Stdio::null()). Closing stdin breaks SSH passphrase / host-key / HTTPS credential-helper prompts, so git genuinely exits non-zero — which run_fetch then surfaced as FAILED.
  • Adds exec_capture_inherit_stdin (stdin inherited, stdout/stderr still piped for the compact summary) and uses it in run_fetch + run_pull. The other ~80 exec_capture callers are untouched and keep stdin closed.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test — zero warnings, 1998 passed / 0 failed (incl. 2 new tests for exec_capture_inherit_stdin).
  • Manual testing: rtk <command> output inspected
    • rtk git fetch origin developok fetched (1 new refs), exit 0 (no false access error); rtk proxy git fetch origin develop parity confirmed.
    • Deterministic before/after (shadow git with a fake on PATH that reports whether git fetch got usable stdin, since rtk resolves git via resolved_command):
      • Pre-fix binary (HEAD~1): child git sees STDIN_RESULT=EOF ← the /dev/null that broke auth.
      • This PR: child git sees STDIN_RESULT=GOT:SENTINEL ← stdin inherited, so ssh/credential helper can read.

Files changed

  • src/core/stream.rs — new exec_capture_inherit_stdin helper + 2 unit tests.
  • src/cmds/git/git.rsrun_fetch and run_pull switched to the new helper; import updated.

…2211)

git fetch/pull ran through exec_capture, which nulls stdin. That breaks
interactive remote authentication (SSH passphrase/host-key prompts, HTTPS
credential helpers), causing git to genuinely fail with 'Could not read from
remote repository' — which run_fetch then surfaced as FAILED. push works
because it inherits stdin (StdinMode::Inherit); ls-remote/clone work via
passthrough.

Add exec_capture_inherit_stdin (stdin inherited, stdout/stderr still piped for
the compact summary) and use it in run_fetch and run_pull. Leaves the 80+ other
exec_capture callers untouched.
@CLAassistant

CLAassistant commented Jun 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@artemgurzhii artemgurzhii marked this pull request as ready for review June 2, 2026 13:56
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.

git fetch falsely reported as access/repository error when it actually succeeds (exit 0)

2 participants