Skip to content

Commit 1921cf9

Browse files
committed
t0061: fix test for argv[0] with spaces (MINGW only)
The test was originally designed for the case where user reported that setting GIT_SSH to a .bat file with spaces in path fails on Windows: git-for-windows#692 The test has two different problems: 1. It succeeds with AND without fix eb7c786 that addressed user's problem. This happens because the core problem was misunderstood, leading to conclusion that git is unable to start any programs with spaces in path on Win7. But in fact a) Bug only affected cmd.exe scripts, such as .bat scripts b) Bug only happened when cmd.exe received at least two quoted args c) Bug happened on any Windows (verified on Win10). Therefore, correct test must involve .bat script and two quoted args. 2. In Visual Studio build, it fails to run, because 'test-fake-ssh.exe' is copied away from its dependencies 'libiconv.dll' and 'zlib1.dll'. Fix both problems by using .bat script instead of 'test-fake-ssh.exe'. NOTE: With this change, the test now correctly fails without eb7c786. Signed-off-by: Alexandr Miloslavskiy <[email protected]>
1 parent 4c86140 commit 1921cf9

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

t/t0061-run-command.sh

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,24 @@ test_expect_success MINGW 'verify curlies are quoted properly' '
210210
test_cmp expect actual
211211
'
212212

213-
test_expect_success MINGW 'can spawn with argv[0] containing spaces' '
214-
cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" ./ &&
215-
test_must_fail "$PWD/test-fake-ssh$X" 2>err &&
216-
grep TRASH_DIRECTORY err
213+
test_expect_success MINGW 'can spawn .bat with argv[0] containing spaces' '
214+
bat_file="$TRASH_DIRECTORY/bat with spaces in name.bat" &&
215+
out_file="bat_out_file.txt" &&
216+
217+
# Every .bat invocation will log its arguments to $out_file
218+
rm -f $out_file &&
219+
printf "echo %%* >> $out_file" >"$bat_file" &&
220+
221+
# Ask git to invoke .bat; clone will fail due to fake SSH helper
222+
test_must_fail env GIT_SSH="$bat_file" git clone myhost:src ssh-clone &&
223+
224+
# Spawning .bat can fail if there are two quoted cmd.exe arguments.
225+
# .bat itself is first (due to spaces in name), so just one more is
226+
# needed to verify. GIT_SSH will invoke .bat multiple times:
227+
# 1) -G myhost
228+
# 2) myhost "git-upload-pack src"
229+
# First invocation will always succeed. Test the second one.
230+
grep "git-upload-pack" "$out_file"
217231
'
218232

219233
test_done

0 commit comments

Comments
 (0)