Merge branch 'js/mingw-spawn-with-spaces-in-path'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Jul 2019 20:59:23 +0000 (13:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Jul 2019 20:59:23 +0000 (13:59 -0700)
Window 7 update ;-)

* js/mingw-spawn-with-spaces-in-path:
mingw: support spawning programs containing spaces in their names

compat/mingw.c
t/t0061-run-command.sh
index d9913463be184fc508610c082f2ec1827898d12d..738f0a826a51b850fcc93f0cadbf707c7eb0b492 100644 (file)
@@ -1437,7 +1437,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
        si.hStdOutput = winansi_get_osfhandle(fhout);
        si.hStdError = winansi_get_osfhandle(fherr);
 
-       if (xutftowcs_path(wcmd, cmd) < 0)
+       if (*argv && !strcmp(cmd, *argv))
+               wcmd[0] = L'\0';
+       else if (xutftowcs_path(wcmd, cmd) < 0)
                return -1;
        if (dir && xutftowcs_path(wdir, dir) < 0)
                return -1;
@@ -1466,8 +1468,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
        wenvblk = make_environment_block(deltaenv);
 
        memset(&pi, 0, sizeof(pi));
-       ret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,
-               wenvblk, dir ? wdir : NULL, &si, &pi);
+       ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL, NULL, TRUE,
+               flags, wenvblk, dir ? wdir : NULL, &si, &pi);
 
        free(wenvblk);
        free(wargs);
index ebc49561acc08e916b2ab78cd84e6729c65f5803..015fac8b5d077165c7f9ac8090fd4e2ac12a7cb3 100755 (executable)
@@ -210,4 +210,10 @@ test_expect_success MINGW 'verify curlies are quoted properly' '
        test_cmp expect actual
 '
 
+test_expect_success MINGW 'can spawn with argv[0] containing spaces' '
+       cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" ./ &&
+       test_must_fail "$PWD/test-fake-ssh$X" 2>err &&
+       grep TRASH_DIRECTORY err
+'
+
 test_done