diff --git a/compat/mingw.c b/compat/mingw.c index 013c938a8ab3ac..4cfa7d3ce45a72 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); @@ -2216,8 +2226,26 @@ 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); + } + 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); diff --git a/compat/mingw.h b/compat/mingw.h index 5adc91c6c7bfb0..5f203458d9395f 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -1,27 +1,30 @@ +#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) #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 @@ -159,8 +162,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); @@ -208,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); @@ -296,8 +305,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 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; 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); diff --git a/config.mak.uname b/config.mak.uname index 9d4ffc4ee39544..56748d1bafaeb0 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 = @@ -529,6 +528,33 @@ ifneq (,$(wildcard ../THIS_IS_MSYSGIT)) else NO_CURL = YesPlease 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 +endif +ifeq (MSYS,$(MSYSTEM)) + prefix = /usr/ +endif +ifneq (,$(MSYSTEM)) + CC = gcc + htmldir = share/doc/git/$(firstword $(subst -, ,$(GIT_VERSION)))/html + INSTALL = /bin/install + NO_R_TO_GCC_LINKER = YesPlease + INTERNAL_QSORT = YesPlease + HAVE_LIBCHARSET_H = YesPlease + NO_GETTEXT = + NO_PYTHON = + USE_LIBPCRE= YesPlease + NO_CURL = + USE_NED_ALLOCATOR = +endif endif ifeq ($(uname_S),QNX) COMPAT_CFLAGS += -DSA_RESTART=0 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. 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/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/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 () { 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"); 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 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 -} diff --git a/t/test-lib.sh b/t/test-lib.sh index eb9c219af7dc8c..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_ () { @@ -942,7 +948,7 @@ test_i18ngrep () { test_lazy_prereq PIPE ' # test whether the filesystem supports FIFOs case $(uname -s) in - CYGWIN*) + CYGWIN*|MINGW*) false ;; *)