From b9e7a5531fbe5e7d3ab2162cfb2f06b9dd67677c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 09:52:07 +0000 Subject: [PATCH 01/19] Help debugging with MSys2 by optionally executing bash with strace MSys2's strace facility is very useful for debugging... With this patch, the bash will be executed through strace if the environment variable GIT_STRACE_COMMANDS is set, which comes in real handy when investigating issues in the test suite. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index 013c938a8ab3ac..8c095bca15dd20 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1071,6 +1071,16 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen free(quoted); } + if (getenv("GIT_STRACE_COMMANDS")) { + char **path = get_path_split(); + cmd = path_lookup("strace.exe", path, 1); + if (!cmd) + return error("strace not found!"); + if (xutftowcs_path(wcmd, cmd) < 0) + return -1; + strbuf_insert(&args, 0, "strace ", 7); + } + wargs = xmalloc((2 * args.len + 1) * sizeof(wchar_t)); xutftowcs(wargs, args.buf, 2 * args.len + 1); strbuf_release(&args); From 8e8c7416c01815caf06964074a3970bb340c6f69 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:18:54 +0000 Subject: [PATCH 02/19] Port header fixes from MSys2 MSys2' Git build script has some changes we should put into Git for Windows' source code proper. Signed-off-by: Johannes Schindelin --- compat/mingw.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 5adc91c6c7bfb0..4b019cc6b628b2 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -1,14 +1,13 @@ +#include +#include #include #include - /* * things that are not available in header files */ -typedef int pid_t; typedef int uid_t; typedef int socklen_t; -#define hstrerror strerror #define S_IFLNK 0120000 /* Symbolic link */ #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) @@ -159,8 +158,10 @@ int pipe(int filedes[2]); unsigned int sleep (unsigned int seconds); int mkstemp(char *template); int gettimeofday(struct timeval *tv, void *tz); +#ifndef __MINGW64_VERSION_MAJOR struct tm *gmtime_r(const time_t *timep, struct tm *result); struct tm *localtime_r(const time_t *timep, struct tm *result); +#endif int getpagesize(void); /* defined in MinGW's libgcc.a */ struct passwd *getpwuid(uid_t uid); int setitimer(int type, struct itimerval *in, struct itimerval *out); @@ -296,8 +297,10 @@ static inline time_t filetime_to_time_t(const FILETIME *ft) /* * Use mingw specific stat()/lstat()/fstat() implementations on Windows. */ +#ifndef __MINGW64_VERSION_MAJOR #define off_t off64_t #define lseek _lseeki64 +#endif /* use struct stat with 64 bit st_size */ #ifdef stat From d594d61c1aabe7e8fabafdc0692d502085b747e6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:19:48 +0000 Subject: [PATCH 03/19] Avoid redefining S_* constants Signed-off-by: Johannes Schindelin --- compat/mingw.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index 4b019cc6b628b2..8921ed1d80d74a 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -13,14 +13,18 @@ typedef int socklen_t; #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) #define S_ISSOCK(x) 0 +#ifndef S_IRWXG #define S_IRGRP 0 #define S_IWGRP 0 #define S_IXGRP 0 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif +#ifndef S_IRWXO #define S_IROTH 0 #define S_IWOTH 0 #define S_IXOTH 0 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#endif #define S_ISUID 0004000 #define S_ISGID 0002000 From e8cb19e5dda672098fa7f33ece0690dd017aa026 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:23:19 +0000 Subject: [PATCH 04/19] Do not re-define _CONSOLE_FONT_INFOEX when compiling with MSys2 MSys2 already has that structure. Signed-off-by: Johannes Schindelin --- compat/winansi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/winansi.c b/compat/winansi.c index efc5bb3a4b6316..aac430a9524758 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -23,6 +23,7 @@ static HANDLE hthread, hread, hwrite; static HANDLE hconsole1, hconsole2; #ifdef __MINGW32__ +#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 5 typedef struct _CONSOLE_FONT_INFOEX { ULONG cbSize; DWORD nFont; @@ -32,6 +33,7 @@ typedef struct _CONSOLE_FONT_INFOEX { WCHAR FaceName[LF_FACESIZE]; } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX; #endif +#endif typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL, PCONSOLE_FONT_INFOEX); From d4fcc46ee370135dc084c6d907b14b0e9379b0a7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:35:10 +0000 Subject: [PATCH 05/19] Start supporting MSys2 in config.mak.uname Signed-off-by: Johannes Schindelin --- config.mak.uname | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index 9d4ffc4ee39544..911c7c0b7efb70 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -529,6 +529,19 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) else NO_CURL = YesPlease endif +ifeq (MINGW32,$(MSYSTEM)) + CC = gcc + htmldir = share/doc/git/$(firstword $(subst -, ,$(GIT_VERSION)))/html + prefix = /mingw32/ + INSTALL = /bin/install + NO_R_TO_GCC_LINKER = YesPlease + INTERNAL_QSORT = YesPlease + HAVE_LIBCHARSET_H = YesPlease + NO_GETTEXT = YesPlease + USE_LIBPCRE= YesPlease + NO_CURL = + USE_NED_ALLOCATOR = +endif endif ifeq ($(uname_S),QNX) COMPAT_CFLAGS += -DSA_RESTART=0 From 393f70f609eaedf77e03ee7549baa70c8dddce3b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:45:37 +0000 Subject: [PATCH 06/19] WIP: Support 64-bit MSys2 Signed-off-by: Johannes Schindelin --- config.mak.uname | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index 911c7c0b7efb70..e21aa7382bfdcc 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -503,12 +503,11 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_POSIX_GOODIES = UnfortunatelyYes DEFAULT_HELP_FORMAT = html NO_D_INO_IN_DIRENT = YesPlease - COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -D_USE_32BIT_TIME_T -DNOGDI -Icompat -Icompat/win32 + COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\" COMPAT_OBJS += compat/mingw.o compat/winansi.o \ compat/win32/pthread.o compat/win32/syslog.o \ compat/win32/dirent.o compat/win32/fscache.o - BASIC_LDFLAGS += -Wl,--large-address-aware EXTLIBS += -lws2_32 GITLIBS += git.res PTHREAD_LIBS = @@ -530,9 +529,20 @@ else NO_CURL = YesPlease endif ifeq (MINGW32,$(MSYSTEM)) + prefix = /mingw32/ +endif +ifeq (MINGW64,$(MSYSTEM)) + prefix = /mingw64/ +else + COMPAT_CFLAGS += -D_USE_32BIT_TIME_T + BASIC_LDFLAGS += -Wl,--large-address-aware +endif +ifeq (MSYS,$(MSYSTEM)) + prefix = /usr/ +endif +ifneq (,$(MSYSTEM)) CC = gcc htmldir = share/doc/git/$(firstword $(subst -, ,$(GIT_VERSION)))/html - prefix = /mingw32/ INSTALL = /bin/install NO_R_TO_GCC_LINKER = YesPlease INTERNAL_QSORT = YesPlease From 5bf9db5118195f09154abde30cc9c87c0e03a737 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 16 Feb 2015 14:06:59 +0100 Subject: [PATCH 07/19] Build Python stuff with MSys2 Signed-off-by: Johannes Schindelin --- config.mak.uname | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.mak.uname b/config.mak.uname index e21aa7382bfdcc..78267dd1cc6436 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -530,9 +530,11 @@ else endif ifeq (MINGW32,$(MSYSTEM)) prefix = /mingw32/ + NO_PYTHON = endif ifeq (MINGW64,$(MSYSTEM)) prefix = /mingw64/ + NO_PYTHON = else COMPAT_CFLAGS += -D_USE_32BIT_TIME_T BASIC_LDFLAGS += -Wl,--large-address-aware From 626bfc1a0d860a990c01ce6d0033e6821c9f9cd5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 17:03:46 +0000 Subject: [PATCH 08/19] Let's use gettext and Python with MSys2 Signed-off-by: Johannes Schindelin --- config.mak.uname | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index 78267dd1cc6436..56748d1bafaeb0 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -549,7 +549,8 @@ ifneq (,$(MSYSTEM)) NO_R_TO_GCC_LINKER = YesPlease INTERNAL_QSORT = YesPlease HAVE_LIBCHARSET_H = YesPlease - NO_GETTEXT = YesPlease + NO_GETTEXT = + NO_PYTHON = USE_LIBPCRE= YesPlease NO_CURL = USE_NED_ALLOCATOR = From af5bef8d6df58471b1a6d7d9cfa6f5ef64324d32 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 14 Feb 2015 15:03:58 +0000 Subject: [PATCH 09/19] Squash compile warning with MSys2 Signed-off-by: Johannes Schindelin --- compat/win32/pthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index 8ad187344fd93e..1ade9617697ec1 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -77,7 +77,7 @@ extern pthread_t pthread_self(void); static inline int pthread_exit(void *ret) { - ExitThread((DWORD)ret); + ExitThread((DWORD)(size_t)ret); } typedef DWORD pthread_key_t; From ad5d003251e852de11a60933bfa2fc29399d7693 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 09:56:35 +0000 Subject: [PATCH 10/19] Error out when mingw_startup() *and* NO_UNSETENV are active The unsetenv code has no idea to update our environ_size, therefore causing segmentation faults when environment variables are removed without compat/mingw.c's knowing (MinGW's optimized lookup would try to strcmp() against NULL in such a case). Signed-off-by: Johannes Schindelin --- compat/mingw.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index 8921ed1d80d74a..5f203458d9395f 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -213,6 +213,10 @@ char *mingw_mktemp(char *template); char *mingw_getcwd(char *pointer, int len); #define getcwd mingw_getcwd +#ifdef NO_UNSETENV +#error "NO_UNSETENV is incompatible with the MinGW startup code!" +#endif + char *mingw_getenv(const char *name); #define getenv mingw_getenv int mingw_putenv(const char *namevalue); From fb3ca797e6330710425f9d221a3a624b53d16a42 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 16:39:10 +0100 Subject: [PATCH 11/19] Special-case the MSYS2_TZ environment variable With MSys2, the "TZ" environment variable gets filtered out when calling non-MSys2 executables. The reason is that Windows' time zone handling is substantially different from the POSIX one. However, we just taught Git for Windows' fork of the MSys2 runtime to pass on the timezone in a different environment variable, MSYS2_TZ for the sole purpose of Git being able to reinterpret it correctly. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index 8c095bca15dd20..2dce8c81e3955d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2226,8 +2226,14 @@ void mingw_startup() __argv[0] = wcstoutfdup_startup(buffer, _wpgmptr, maxlen); for (i = 1; i < argc; i++) __argv[i] = wcstoutfdup_startup(buffer, wargv[i], maxlen); - for (i = 0; wenv[i]; i++) + for (i = 0; wenv[i]; i++) { environ[i] = wcstoutfdup_startup(buffer, wenv[i], maxlen); + if (starts_with(environ[i], "MSYS2_TZ=")) { + char *to_free = environ[i]; + environ[i] = xstrdup(to_free + 6); + free(to_free); + } + } environ[i] = NULL; free(buffer); From 93dd46ccbf6d077ae8ba04fb97d48e260a7f3361 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:55:48 +0000 Subject: [PATCH 12/19] Tests (MinGW): Do not bother to test funny file names MSys2 actually allows to create files or directories whose names contain tabs, newlines or colors, even if plain Win32 API cannot access them. As we are using an MSys2 bash to run the tests, such files or directories are created successfully, but Git has no chance to work with them because it is a regular Windows program, hence limited by the Win32 API. Signed-off-by: Johannes Schindelin --- t/t3300-funny-names.sh | 1 + t/t3600-rm.sh | 3 ++- t/t3703-add-magic-pathspec.sh | 2 +- t/t3902-quoted.sh | 1 + t/t4016-diff-quote.sh | 1 + t/t4135-apply-weird-filenames.sh | 3 ++- t/t9903-bash-prompt.sh | 2 +- 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index 9a146f13353938..04de03cad0a746 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -13,6 +13,7 @@ tree, index, and tree objects. HT=' ' +test_have_prereq MINGW || echo 2>/dev/null > "Name with an${HT}HT" if ! test -f "Name with an${HT}HT" then diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index e00d7d2b618602..83b1df9e3c4d2c 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -14,7 +14,8 @@ test_expect_success \ git add -- foo bar baz 'space embedded' -q && git commit -m 'add normal files'" -if touch -- 'tab embedded' 'newline + +if ! test_have_prereq MINGW && touch -- 'tab embedded' 'newline embedded' 2>/dev/null then test_set_prereq FUNNYNAMES diff --git a/t/t3703-add-magic-pathspec.sh b/t/t3703-add-magic-pathspec.sh index 5115de7036c38a..aaff784659de81 100755 --- a/t/t3703-add-magic-pathspec.sh +++ b/t/t3703-add-magic-pathspec.sh @@ -38,7 +38,7 @@ cat >expected </dev/null +if ! test_have_prereq MINGW && mkdir ":" 2>/dev/null then test_set_prereq COLON_DIR fi diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh index 892f5678441b3c..f528008c363c68 100755 --- a/t/t3902-quoted.sh +++ b/t/t3902-quoted.sh @@ -12,6 +12,7 @@ GN='純' HT=' ' DQ='"' +test_have_prereq MINGW || echo foo 2>/dev/null > "Name and an${HT}HT" if ! test -f "Name and an${HT}HT" then diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index cd543ecc5429dc..9c48e5c2c99ad1 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -13,6 +13,7 @@ P1='pathname with HT' P2='pathname with SP' P3='pathname with LF' +test_have_prereq !MINGW && echo 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || { skip_all='Your filesystem does not allow tabs in filenames' test_done diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh index bf5dc57286493b..6d6b96d5d37715 100755 --- a/t/t4135-apply-weird-filenames.sh +++ b/t/t4135-apply-weird-filenames.sh @@ -19,7 +19,8 @@ test_expect_success 'setup' ' test_when_finished "rm -f \"tab embedded.txt\"" && test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" && - if touch -- "tab embedded.txt" '\''"quoteembedded".txt'\'' + if ! test_have_prereq MINGW && + touch -- "tab embedded.txt" '\''"quoteembedded".txt'\'' then test_set_prereq FUNNYNAMES fi diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 915098418495b4..5ca51d7219d708 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -65,7 +65,7 @@ repo_with_newline='repo with newline' -if mkdir "$repo_with_newline" 2>/dev/null +if ! test_have_prereq MINGW && mkdir "$repo_with_newline" 2>/dev/null then test_set_prereq FUNNYNAMES else From 34fc6de873c9ad88c18c1d22ca1bb18687ea90b8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 12:25:42 +0000 Subject: [PATCH 13/19] Tests (MinGW): Disable mkfifo-based tests With MSys2, there is actually an implementation of mkfifo available. The only problem is that it is only emulating named pipes through the MSys2 runtime; The Win32 API has no idea about named pipes, hence the Git executable cannot access those pipes either. The symptom is that Git fails with a ': No such file or directory' because MSys2 emulates named pipes through special-crafted '.lnk' files. The solution is to tell the test suite explicitly that we cannot use named pipes when we want to test a MinGW Git. Signed-off-by: Johannes Schindelin --- t/test-lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index eb9c219af7dc8c..20bd2ff3484bb5 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -942,7 +942,7 @@ test_i18ngrep () { test_lazy_prereq PIPE ' # test whether the filesystem supports FIFOs case $(uname -s) in - CYGWIN*) + CYGWIN*|MINGW*) false ;; *) From 3153820216f1ccc5e2a4b559d7d920a2167bd6e4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 12:44:24 +0000 Subject: [PATCH 14/19] fixup! t5000: Fix CRLF vs LF issue MSys2's `tr` does not introduce any CRLFs... This reverts commit 01a6f1b2480e62967dff9bfc31f78f15048f1329. Signed-off-by: Johannes Schindelin --- t/t5000-tar-tree.sh | 3 --- t/test-lib-functions.sh | 8 -------- 2 files changed, 11 deletions(-) diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index edf9edb03a7f76..7b8babd89b22dc 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -240,11 +240,9 @@ test_expect_success 'archive --list shows only enabled remote filters' ' test_expect_success 'invoke tar filter by format' ' git archive --format=tar.foo HEAD >config.tar.foo && tr ab ba config.tar && - d2u_force config.tar && test_cmp_bin b.tar config.tar && git archive --format=bar HEAD >config.bar && tr ab ba config.tar && - d2u_force config.tar && test_cmp_bin b.tar config.tar ' @@ -269,7 +267,6 @@ test_expect_success 'only enabled filters are available remotely' ' test_must_fail git archive --remote=. --format=tar.foo HEAD \ >remote.tar.foo && git archive --remote=. --format=bar >remote.bar HEAD && - d2u_force config.bar && test_cmp_bin remote.bar config.bar ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 729b33ab1e73af..dafd6ad21a92ba 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -866,11 +866,3 @@ mingw_read_file_strip_cr_ () { eval "$1=\$$1\$line" done } - -# Perform dos2unix line ending conversion for binary files -d2u_force() { - if test_have_prereq MINGW - then - dos2unix --force "$1" - fi -} From a9b3c2b4081d81a6c9a1240d9990cc7099c04314 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 15:20:16 +0000 Subject: [PATCH 15/19] t5516: override MinGW-specific pwd override This test is susceptible to MSys2's posix-to-windows path mangling; Let's just use POSIX paths throughout and let the tests pass. Signed-off-by: Johannes Schindelin --- t/t5516-fetch-push.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 0df32106933448..56a16a92cc77fc 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -15,6 +15,14 @@ This test checks the following functionality: . ./test-lib.sh +if test_have_prereq MINGW +then + # Avoid posix-to-windows path mangling + pwd () { + builtin pwd + } +fi + D=`pwd` mk_empty () { From 5c658f4f5b99b656ea9b6fedf77cd9b957f0579d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 14:21:04 +0000 Subject: [PATCH 16/19] Tests: optionally skip redirecting stdin/stdout/stderr There is a really useful debugging technique developed by Sverre Rabbelier that inserts "bash &&" somewhere in the test scripts, letting the developer interact at given points with the current state. Another debugging technique, used a lot by this here coder, is to run certain executables via gdb by guarding a "gdb -args" call in bin-wrappers/git. Both techniques were disabled by 781f76b1(test-lib: redirect stdin of tests). Let's reinstate the ability to run an interactive shell by making the redirection optional: setting the TEST_NO_REDIRECT environment variable will skip the redirection. Signed-off-by: Johannes Schindelin --- t/test-lib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 20bd2ff3484bb5..f3736ccd0af802 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -17,6 +17,7 @@ # for git on windows so stdin will not be misdetected as attached to a # terminal +test -z "$TEST_NO_REDIRECT" || exec < /dev/null # Keep the original TERM for say_color @@ -524,7 +525,12 @@ maybe_setup_valgrind () { test_eval_ () { # This is a separate function because some tests use # "return" to end a test_expect_success block early. - eval &3 2>&4 "$*" + if test -z "$TEST_NO_REDIRECT" + then + eval &3 2>&4 "$*" + else + eval "$*" + fi } test_run_ () { From 1f8add0600be433a170bf6ee20fb5c06cde3ebb6 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 15:41:20 +0000 Subject: [PATCH 17/19] mingw: Prepare the TMP environment variable for shell scripts When shell scripts access a $TMP variable containing backslashes, they will be mistaken for escape characters. Let's not let that happen by converting them to forward slashes. This fixes t7800 with MSys2. Signed-off-by: Johannes Schindelin --- compat/mingw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index 2dce8c81e3955d..4cfa7d3ce45a72 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2233,6 +2233,18 @@ void mingw_startup() environ[i] = xstrdup(to_free + 6); free(to_free); } + if (starts_with(environ[i], "TMP=")) { + /* + * Convert all dir separators to forward slashes, + * to help shell commands called from the Git + * executable (by not mistaking the dir separators + * for escape characters. + */ + char *p; + for (p = environ[i]; *p; p++) + if (*p == '\\') + *p = '/'; + } } environ[i] = NULL; free(buffer); From b528e9430ac5f58814c5102f5fff2cb0463005c3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 13:33:35 +0000 Subject: [PATCH 18/19] Git.pm: stop assuming that absolute paths start with a slash This fixes t7800 with MSys2. Signed-off-by: Johannes Schindelin --- perl/Git.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perl/Git.pm b/perl/Git.pm index 204fdc673754c8..0f74f710ae625f 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -188,7 +188,8 @@ sub repository { }; if ($dir) { - $dir =~ m#^/# or $dir = $opts{Directory} . '/' . $dir; + _verify_require(); + File::Spec->file_name_is_absolute($dir) or $dir = $opts{Directory} . '/' . $dir; $opts{Repository} = abs_path($dir); # If --git-dir went ok, this shouldn't die either. From 119830d2d6f79125dbe38f87e4d4bb5f518ddbae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 16:08:36 +0000 Subject: [PATCH 19/19] MSys2: Fix t9700 assumption about directory separators This test assumed that there are no two equivalent directory separators. However, on Windows, the back slash and the forward slash *are* equivalent. Let's paper over this issue by converting the backward slashes to forward ones in the test that fails with MSys2 otherwise. Signed-off-by: Johannes Schindelin --- t/t9700/test.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/t9700/test.pl b/t/t9700/test.pl index 1140767b50706f..a01665473d5d5a 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -33,7 +33,9 @@ BEGIN is($r->config_int("test.nonexistent"), undef, "config_int: nonexistent"); ok($r->config_bool("test.booltrue"), "config_bool: true"); ok(!$r->config_bool("test.boolfalse"), "config_bool: false"); -is($r->config_path("test.path"), $r->config("test.pathexpanded"), +our $test_path = $r->config_path("test.path"); +$test_path =~ s/\\/\//g if ($^O eq 'msys'); +is($test_path, $r->config("test.pathexpanded"), "config_path: ~/foo expansion"); is_deeply([$r->config_path("test.pathmulti")], ["foo", "bar"], "config_path: multiple values");