Skip to content

Commit 3064d5a

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4b0abd5 commit 3064d5a

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ TEST_PROGRAMS_NEED_X += test-delta
583583
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
584584
TEST_PROGRAMS_NEED_X += test-dump-split-index
585585
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
586+
TEST_PROGRAMS_NEED_X += test-fake-ssh
586587
TEST_PROGRAMS_NEED_X += test-genrandom
587588
TEST_PROGRAMS_NEED_X += test-hashmap
588589
TEST_PROGRAMS_NEED_X += test-index-version

t/t5601-clone.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ test_description=clone
44

55
. ./test-lib.sh
66

7+
X=
8+
test_have_prereq !MINGW || X=.exe
9+
710
test_expect_success setup '
811
912
rm -fr .git &&
@@ -282,23 +285,18 @@ test_expect_success 'clone checking out a tag' '
282285

283286
setup_ssh_wrapper () {
284287
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" &&
293291
export GIT_SSH &&
294292
export TRASH_DIRECTORY &&
295293
>"$TRASH_DIRECTORY"/ssh-output
296294
'
297295
}
298296

299297
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" &&
302300
export GIT_SSH
303301
}
304302

test-fake-ssh.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)