Skip to content

Commit

Permalink
fix(sync): explicitly close stdin for child processes
Browse files Browse the repository at this point in the history
In some circumstances, `git fetch` will hang because it's waiting on credentials, but this isn't surfaced to the user. To prevent that from happening, close the child process's stdin unless we have something to write to it.

Actually, upon testing this commit, it doesn't seem to work, but it also probably doesn't hurt to check in. We would want to suppress the "askpass" mechanism somehow (see the `GIT_ASKPASS` environment variable).
  • Loading branch information
arxanas committed Jun 22, 2022
1 parent ea94c05 commit 0d75fe9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions git-branchless-lib/src/git/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ impl GitRunInfo {
command.env(BRANCHLESS_TRANSACTION_ID_ENV_VAR, event_tx_id.to_string());
}

if stdin.is_some() {
command.stdin(Stdio::piped());
}
command.stdin(match stdin {
Some(_) => Stdio::piped(),
None => Stdio::null(),
});
command.stdout(Stdio::piped());
command.stderr(Stdio::piped());

Expand Down

0 comments on commit 0d75fe9

Please sign in to comment.