mingw: fix t5601-clone.sh
Since baaf233 (connect: improve check for plink to reduce false positives, 2015-04-26), t5601 writes out a `plink.exe` for testing that is actually a shell script. So the assumption that the `.exe` extension implies that the file is *not* a shell script is now wrong. Since there was no love for the idea of allowing `.exe` files to be shell scripts on Windows, let's go the other way round: *make* `plink.exe` a real `.exe`. This fixes t5601-clone.sh in Git for Windows' SDK. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jan 27, 2016 at 17:19 UTC
3064d5a38c72532e603faed4c63042b375ded2c7
3 files changed
+39
-10
Makefile
+1
@@ -583,6 +583,7 @@ TEST_PROGRAMS_NEED_X += test-delta
583
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
584
TEST_PROGRAMS_NEED_X += test-dump-split-index
585
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
586
+TEST_PROGRAMS_NEED_X += test-fake-ssh
587
TEST_PROGRAMS_NEED_X += test-genrandom
588
TEST_PROGRAMS_NEED_X += test-hashmap
589
TEST_PROGRAMS_NEED_X += test-index-version
t/t5601-clone.sh
+8
-10
@@ -4,6 +4,9 @@ test_description=clone
4
5
. ./test-lib.sh
6
7
+X=
8
+test_have_prereq !MINGW || X=.exe
9
+
10
test_expect_success setup '
11
12
rm -fr .git &&
@@ -282,14 +285,9 @@ test_expect_success 'clone checking out a tag' '
285
286
setup_ssh_wrapper () {
287
test_expect_success 'setup ssh wrapper' '
285
- write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
286
- echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
287
- # throw away all but the last argument, which should be the
288
- # command
289
- while test $# -gt 1; do shift; done
290
- eval "$1"
291
- EOF
292
- GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
288
+ cp "$GIT_BUILD_DIR/test-fake-ssh$X" \
289
+ "$TRASH_DIRECTORY/ssh-wrapper$X" &&
290
+ GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper$X" &&
291
export GIT_SSH &&
292
export TRASH_DIRECTORY &&
293
>"$TRASH_DIRECTORY"/ssh-output
@@ -297,8 +295,8 @@ setup_ssh_wrapper () {
295
}
296
297
copy_ssh_wrapper_as () {
300
- cp "$TRASH_DIRECTORY/ssh-wrapper" "$1" &&
301
- GIT_SSH="$1" &&
298
+ cp "$TRASH_DIRECTORY/ssh-wrapper$X" "${1%$X}$X" &&
299
+ GIT_SSH="${1%$X}$X" &&
300
export GIT_SSH
301
}
302
test-fake-ssh.c
new
+30
@@ -0,0 +1,30 @@
1
+#include "git-compat-util.h"
2
+#include "run-command.h"
3
+#include "strbuf.h"
4
+
5
+int main(int argc, char **argv)
6
+{
7
+ const char *trash_directory = getenv("TRASH_DIRECTORY");
8
+ struct strbuf buf = STRBUF_INIT;
9
+ FILE *f;
10
+ int i;
11
+ const char *child_argv[] = { NULL, NULL };
12
+
13
+ /* First, print all parameters into $TRASH_DIRECTORY/ssh-output */
14
+ if (!trash_directory)
15
+ die("Need a TRASH_DIRECTORY!");
16
+ strbuf_addf(&buf, "%s/ssh-output", trash_directory);
17
+ f = fopen(buf.buf, "w");
18
+ if (!f)
19
+ die("Could not write to %s", buf.buf);
20
+ for (i = 0; i < argc; i++)
21
+ fprintf(f, "%s%s", i > 0 ? " " : "", i > 0 ? argv[i] : "ssh:");
22
+ fprintf(f, "\n");
23
+ fclose(f);
24
+
25
+ /* Now, evaluate the *last* parameter */
26
+ if (argc < 2)
27
+ return 0;
28
+ child_argv[0] = argv[argc - 1];
29
+ return run_command_v_opt(child_argv, RUN_USING_SHELL);
30
+}