Skip to content

Commit 1cc4a6d

Browse files
committed
Workaround hanging git process when initially called from VS Code.
1 parent 1789f33 commit 1cc4a6d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# WSLGit Changelog
22

33

4-
## [0.3.0] - in development
4+
## [0.3.0] - 2017-11-08
55

66
### Added
77

88
- Add proper license (MIT).
99

10+
### Fixed
11+
12+
- Git waiting for input when called from VS Code to check if `git --version`
13+
works.
14+
1015

1116
## [0.2.0] - 2017-07-27
1217

src/main.rs

+14
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,24 @@ fn main() {
6666
.map(translate_path_to_unix)
6767
.map(shell_escape));
6868
let git_cmd = git_args.join(" ");
69+
let stdin_mode = if git_cmd.ends_with("--version") {
70+
// For some reason, the git subprocess seems to hang, waiting for
71+
// input, when VS Code 1.17.2 tries to detect if `git --version` works
72+
// on Windows 10 1709 (specifically, in `findSpecificGit` in the
73+
// VS Code source file `extensions/git/src/git.ts`).
74+
// To workaround this, we only pass stdin to the git subprocess
75+
// for all other commands, but not for the initial `--version` check.
76+
// Stdin is needed for example when commiting, where the commit
77+
// message is passed on stdin.
78+
Stdio::null()
79+
} else {
80+
Stdio::inherit()
81+
};
6982
let git_proc = Command::new("bash")
7083
.arg("-i")
7184
.arg("-c")
7285
.arg(&git_cmd)
86+
.stdin(stdin_mode)
7387
.stdout(Stdio::piped())
7488
.spawn()
7589
.expect(&format!("Failed to execute command '{}'", &git_cmd));

0 commit comments

Comments
 (0)