fix(git): inherit stdin for git fetch/pull so SSH auth works (#2211)#2215
Closed
artemgurzhii wants to merge 1 commit into
Closed
fix(git): inherit stdin for git fetch/pull so SSH auth works (#2211)#2215artemgurzhii wants to merge 1 commit into
artemgurzhii wants to merge 1 commit into
Conversation
…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.
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.
Summary
rtk git fetch/pullno longer fail with a falsefatal: Could not read from remote repositoryerror when the remote needs interactive auth.run_fetch/run_pullusedexec_capture, which hardcodesstdin(Stdio::null()). Closing stdin breaks SSH passphrase / host-key / HTTPS credential-helper prompts, so git genuinely exits non-zero — whichrun_fetchthen surfaced asFAILED.exec_capture_inherit_stdin(stdin inherited, stdout/stderr still piped for the compact summary) and uses it inrun_fetch+run_pull. The other ~80exec_capturecallers 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 forexec_capture_inherit_stdin).rtk <command>output inspectedrtk git fetch origin develop→ok fetched (1 new refs), exit0(no false access error);rtk proxy git fetch origin developparity confirmed.gitwith a fake onPATHthat reports whethergit fetchgot usable stdin, since rtk resolvesgitviaresolved_command):HEAD~1): child git seesSTDIN_RESULT=EOF← the/dev/nullthat broke auth.STDIN_RESULT=GOT:SENTINEL← stdin inherited, sossh/credential helper can read.Files changed
src/core/stream.rs— newexec_capture_inherit_stdinhelper + 2 unit tests.src/cmds/git/git.rs—run_fetchandrun_pullswitched to the new helper; import updated.