From cdc1844c3d054733891afbb486078b23c99562f9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 26 Jul 2009 05:08:42 +0200 Subject: [PATCH 01/25] Handle http.* config variables pointing to files gracefully on Windows On Windows, we would like to be able to have a default http.sslCAinfo that points to an MSys path (i.e. relative to the installation root of Git). As Git is a MinGW program, it has to handle the conversion of the MSys path into a MinGW32 path itself. Since system_path() considers paths starting with '/' as absolute, we have to convince it to make a Windows path by stripping the leading slash. Signed-off-by: Johannes Schindelin --- http.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/http.c b/http.c index 6798620065..4564a63bcb 100644 --- a/http.c +++ b/http.c @@ -8,6 +8,7 @@ #include "credential.h" #include "version.h" #include "pkt-line.h" +#include "exec_cmd.h" int active_requests; int http_is_verbose; @@ -147,6 +148,18 @@ static void process_curl_messages(void) } #endif +static int git_config_path(const char **result, + const char *var, const char *value) +{ + if (git_config_string(result, var, value)) + return 1; +#ifdef __MINGW32__ + if (**result == '/') + *result = system_path((*result) + 1); +#endif + return 0; +} + static int http_options(const char *var, const char *value, void *cb) { if (!strcmp("http.sslverify", var)) { @@ -154,17 +167,17 @@ static int http_options(const char *var, const char *value, void *cb) return 0; } if (!strcmp("http.sslcert", var)) - return git_config_string(&ssl_cert, var, value); + return git_config_path(&ssl_cert, var, value); #if LIBCURL_VERSION_NUM >= 0x070903 if (!strcmp("http.sslkey", var)) - return git_config_string(&ssl_key, var, value); + return git_config_path(&ssl_key, var, value); #endif #if LIBCURL_VERSION_NUM >= 0x070908 if (!strcmp("http.sslcapath", var)) - return git_config_string(&ssl_capath, var, value); + return git_config_path(&ssl_capath, var, value); #endif if (!strcmp("http.sslcainfo", var)) - return git_config_string(&ssl_cainfo, var, value); + return git_config_path(&ssl_cainfo, var, value); if (!strcmp("http.sslcertpasswordprotected", var)) { ssl_cert_password_required = git_config_bool(var, value); return 0; From f050e3452cd95cbdebbf4c4158b4078986c93812 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Thu, 29 Aug 2013 13:09:27 +0200 Subject: [PATCH 02/25] MinGW: Use MakeMaker to build the Perl libraries This way the libraries get properly installed into the "site_perl" directory and we just have to move them out of the "mingw" directory. Signed-off-by: Sebastian Schuberth --- config.mak.uname | 1 - 1 file changed, 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index b64b63c34c..e9642f844e 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -495,7 +495,6 @@ ifneq (,$(findstring MINGW,$(uname_S))) NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease NO_SVN_TESTS = YesPlease - NO_PERL_MAKEMAKER = YesPlease RUNTIME_PREFIX = YesPlease NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease NO_NSEC = YesPlease From 174818b131d7518bd337dcfce0a34a8e35946132 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 4 Sep 2013 18:18:49 +0200 Subject: [PATCH 03/25] Makefile: Set htmldir to match the default HTML docs location under MSYS Signed-off-by: Sebastian Schuberth --- config.mak.uname | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index e9642f844e..4eeb7ddb78 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -526,7 +526,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) X = .exe SPARSE_FLAGS = -Wno-one-bit-signed-bitfield ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) - htmldir = doc/git/html/ + htmldir = share/doc/git/$(firstword $(subst -, ,$(GIT_VERSION)))/html prefix = INSTALL = /bin/install EXTLIBS += /mingw/lib/libz.a From bba44dc2cb472885dd0fc44293e99eff69ebd895 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 3 Sep 2014 23:37:54 +0200 Subject: [PATCH 04/25] Enable support for perl regular expressions (LIBPCRE) Signed-off-by: Thomas Braun --- config.mak.uname | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.uname b/config.mak.uname index 4eeb7ddb78..74f7f1a41f 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -534,6 +534,7 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) INTERNAL_QSORT = YesPlease HAVE_LIBCHARSET_H = YesPlease NO_GETTEXT = YesPlease + USE_LIBPCRE= YesPlease else NO_CURL = YesPlease endif From 8bb5b6e167292ce95f4a676159d57b5d786c1401 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 09:52:07 +0000 Subject: [PATCH 05/25] 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 70f3191a4f..87ddb1d3e2 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1011,6 +1011,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 8a8d66c4d676f75ee803762383f4ef4243a00a75 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:18:54 +0000 Subject: [PATCH 06/25] Assorted header fixes to support MSys2-based MinGW build The excellent MSys2 project brings a substantially updated MinGW environment including newer GCC versions and new headers. To support compiling Git, let's special-case the new MinGW (tell-tale: the _MINGW64_VERSION_MAJOR constant is defined). Signed-off-by: Johannes Schindelin --- compat/mingw.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 5e499cfb71..57fa91e28d 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) @@ -92,8 +91,10 @@ static inline int symlink(const char *oldpath, const char *newpath) { errno = ENOSYS; return -1; } static inline int fchmod(int fildes, mode_t mode) { errno = ENOSYS; return -1; } +#ifndef __MINGW64_VERSION_MAJOR static inline pid_t fork(void) { errno = ENOSYS; return -1; } +#endif static inline unsigned int alarm(unsigned int seconds) { return 0; } static inline int fsync(int fd) @@ -164,8 +165,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); @@ -285,8 +288,10 @@ static inline int getrlimit(int resource, struct rlimit *rlp) /* * 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 @@ -359,8 +364,12 @@ static inline char *mingw_find_last_dir_sep(const char *path) int mingw_offset_1st_component(const char *path); #define offset_1st_component mingw_offset_1st_component #define PATH_SEP ';' +#ifndef __MINGW64_VERSION_MAJOR #define PRIuMAX "I64u" #define PRId64 "I64d" +#else +#include +#endif void mingw_open_html(const char *path); #define open_html mingw_open_html From f94d58d5524202b2eda3f825bf653cda37225901 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:19:48 +0000 Subject: [PATCH 07/25] 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 57fa91e28d..06a51f0655 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 8505e79fab53793fb53f849c06349a04f1dc5135 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:23:19 +0000 Subject: [PATCH 08/25] 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 efc5bb3a4b..aac430a952 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 55f0555dbdc487b4474360e571f047f5593f4fec Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:35:10 +0000 Subject: [PATCH 09/25] Start supporting MSys2 in config.mak.uname Signed-off-by: Johannes Schindelin --- config.mak.uname | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index 74f7f1a41f..a6e9b45eba 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -534,9 +534,23 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) INTERNAL_QSORT = YesPlease HAVE_LIBCHARSET_H = YesPlease NO_GETTEXT = YesPlease - USE_LIBPCRE= YesPlease else - NO_CURL = YesPlease + ifeq ($(shell expr "$(uname_R)" : '2\.'),2) + # MSys2 + 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 = + else + NO_CURL = YesPlease + endif endif endif ifeq ($(uname_S),QNX) From 35bd8f96ff474c121701d9e8cf856426cb1a412f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 13 Feb 2015 12:45:37 +0000 Subject: [PATCH 10/25] Start supporting 64-bit MSys2 This just makes things compile, the test suite most likely needs extra tender loving care in addition to this change. While at it, also allow building MSys2 Git (i.e. a Git that uses MSys2's POSIX emulation layer). Signed-off-by: Johannes Schindelin --- config.mak.uname | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/config.mak.uname b/config.mak.uname index a6e9b45eba..4dcbe38cc8 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -511,13 +511,12 @@ 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 BASIC_CFLAGS += -DPROTECT_NTFS_DEFAULT=1 - BASIC_LDFLAGS += -Wl,--large-address-aware EXTLIBS += -lws2_32 GITLIBS += git.res PTHREAD_LIBS = @@ -537,9 +536,18 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) else ifeq ($(shell expr "$(uname_R)" : '2\.'),2) # MSys2 + prefix = /usr/ + 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 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 ff5c75bcbf27c2435f1a46b890345fd2329e775e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 16 Feb 2015 14:06:59 +0100 Subject: [PATCH 11/25] Build Python stuff with MSys2 Signed-off-by: Johannes Schindelin --- config.mak.uname | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.uname b/config.mak.uname index 4dcbe38cc8..f9e95e1aa9 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -556,6 +556,7 @@ else USE_LIBPCRE= YesPlease NO_CURL = USE_NED_ALLOCATOR = + NO_PYTHON = else NO_CURL = YesPlease endif From 63d6524d8c2ca48f99c7833957588370ccde523a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 17:03:46 +0000 Subject: [PATCH 12/25] Let's use gettext with MSys2 Signed-off-by: Johannes Schindelin --- config.mak.uname | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mak.uname b/config.mak.uname index f9e95e1aa9..0f314297e9 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -552,7 +552,7 @@ else NO_R_TO_GCC_LINKER = YesPlease INTERNAL_QSORT = YesPlease HAVE_LIBCHARSET_H = YesPlease - NO_GETTEXT = YesPlease + NO_GETTEXT = USE_LIBPCRE= YesPlease NO_CURL = USE_NED_ALLOCATOR = From d697d998bd540ed6057e6d50bf7dd9234b405804 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 24 Feb 2015 15:09:31 +0000 Subject: [PATCH 13/25] Do not trust MSys2's MinGW gettext.sh It does not quite work because it produces DOS line endings which the shell does not like at all. This lets t3406, t3903, t4254, t7400, t7401, t7406 and t7407 pass. Signed-off-by: Johannes Schindelin --- config.mak.uname | 1 + 1 file changed, 1 insertion(+) diff --git a/config.mak.uname b/config.mak.uname index 0f314297e9..00d0529ec7 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -553,6 +553,7 @@ else INTERNAL_QSORT = YesPlease HAVE_LIBCHARSET_H = YesPlease NO_GETTEXT = + USE_GETTEXT_SCHEME = fallthrough USE_LIBPCRE= YesPlease NO_CURL = USE_NED_ALLOCATOR = From 4826853b5e30409fc120cc09b8a205ba5cf7b417 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 14 Feb 2015 15:03:58 +0000 Subject: [PATCH 14/25] 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 8ad187344f..1ade961769 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 53c9de986f8acd5cccb1520d91fff272cdec2fe9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 09:56:35 +0000 Subject: [PATCH 15/25] 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 06a51f0655..cbd989a0b9 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -220,6 +220,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 a629f48bfe3bd346af3c8476edda7fc50607d965 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 15 Feb 2015 16:39:10 +0100 Subject: [PATCH 16/25] 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 87ddb1d3e2..b83f163f28 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2103,8 +2103,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 (!strncasecmp(environ[i], "MSYS2_TZ=", 9)) { + char *to_free = environ[i]; + environ[i] = xstrdup(to_free + 6); + free(to_free); + } + } environ[i] = NULL; free(buffer); From 1a8c0b9bf9f6a60ad3728ccedd86b3d4acaee4eb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 18 Feb 2015 11:55:48 +0000 Subject: [PATCH 17/25] 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 9a146f1335..04de03cad0 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 e00d7d2b61..83b1df9e3c 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 5115de7036..aaff784659 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 892f567844..f528008c36 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 cd543ecc54..9c48e5c2c9 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 bf5dc57286..6d6b96d5d3 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 51ecd3e4c1..c5bf838e9c 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -67,7 +67,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 37ab763b00dfffa3200f753aef6fb7690ffcaeba Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 12:25:42 +0000 Subject: [PATCH 18/25] 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 c09677802c..6232520684 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -980,7 +980,7 @@ test_i18ngrep () { test_lazy_prereq PIPE ' # test whether the filesystem supports FIFOs case $(uname -s) in - CYGWIN*) + CYGWIN*|MINGW*) false ;; *) From 072a4f50b72600e9266d50ab95a85e331f7dfa27 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 19 Feb 2015 15:20:16 +0000 Subject: [PATCH 19/25] 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 594d7a6998..e101de914a 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -16,6 +16,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 75a993e7255a4ba9e5a634ffc1225e09e675730a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 14:21:04 +0000 Subject: [PATCH 20/25] 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/t/test-lib.sh b/t/test-lib.sh index 6232520684..4eb3ffc7fa 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -506,6 +506,20 @@ test_eval_ () { # # The test itself is run with stderr put back to &4 (so either to # /dev/null, or to the original stderr if --verbose was used). + if test -n "$TEST_NO_REDIRECT" + then + test_eval_inner_ "$@" + test_eval_ret_=$? + if test "$trace" = t + then + set +x + if test "$test_eval_ret_" != 0 + then + say_color error >&4 "error: last command exited with \$?=$test_eval_ret_" + fi + fi + return $test_eval_ret_ + fi { test_eval_inner_ "$@" &3 2>&4 test_eval_ret_=$? From e012fbbdbef7d119f5e826687e42bcb0bac1595e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 20 Feb 2015 15:41:20 +0000 Subject: [PATCH 21/25] 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 b83f163f28..9e63ac8529 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -2110,6 +2110,18 @@ void mingw_startup() environ[i] = xstrdup(to_free + 6); free(to_free); } + if (!strncasecmp(environ[i], "TMP=", 4)) { + /* + * 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 38f9a93b200f491dfbd8a27fc2a1b9efcaa9c409 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 13:33:35 +0000 Subject: [PATCH 22/25] 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 9026a7bb98..d1e4c48202 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 6d1d74cd44a2e77ee51a8bd2175397721ad69449 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 16:08:36 +0000 Subject: [PATCH 23/25] 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 1140767b50..a01665473d 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -33,7 +33,9 @@ is($r->config_int("test.int"), 2048, "config_int: integer"); 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"); From 9bab9e8c22b2c9579079edb881620d0d3bd65a2a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 22 Feb 2015 19:55:26 +0000 Subject: [PATCH 24/25] mingw: Make sure sigset_t is defined With MSys2, the sigset_t type is defined in sys/types.h, therefore we need to #include said file. 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 cbd989a0b9..efc27c4fff 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -1,5 +1,9 @@ #include #include +#include +#ifndef _POSIX +typedef _sigset_t sigset_t; +#endif #include #include /* From 66ee249f3b4f17fa07ebb3f9076c6fb7bb5b6a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A7=88=EB=88=84=EC=97=98?= Date: Fri, 6 Mar 2015 12:09:51 +0100 Subject: [PATCH 25/25] mingw: Try to delete target directory first. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the rename function tries to move a directory it fails if the target directory exists. It should check if it can delete the (possibly empty) target directory and then try again to move the directory. Helped-by: Johannes Schindelin Signed-off-by: 마누엘 --- compat/mingw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compat/mingw.c b/compat/mingw.c index 9e63ac8529..b8675ae314 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1594,7 +1594,12 @@ repeat: if (gle == ERROR_ACCESS_DENIED && (attrs = GetFileAttributesW(wpnew)) != INVALID_FILE_ATTRIBUTES) { if (attrs & FILE_ATTRIBUTE_DIRECTORY) { - errno = EISDIR; + DWORD attrsold = GetFileAttributesW(wpold); + if (attrsold == INVALID_FILE_ATTRIBUTES || + !(attrsold & FILE_ATTRIBUTE_DIRECTORY)) + errno = EISDIR; + else if (!_wrmdir(wpnew)) + goto repeat; return -1; } if ((attrs & FILE_ATTRIBUTE_READONLY) &&