mirror of
https://github.com/git/git.git
synced 2026-02-07 00:05:02 +00:00
Merge pull request #26 from dscho/msys2
Fixes required to build Git for Windows with MSys2
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
#include <stdint.h>
|
||||
#include <wchar.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,7 +38,7 @@ cat >expected <<EOF
|
||||
add 'sub/foo'
|
||||
EOF
|
||||
|
||||
if mkdir ":" 2>/dev/null
|
||||
if ! test_have_prereq MINGW && mkdir ":" 2>/dev/null
|
||||
then
|
||||
test_set_prereq COLON_DIR
|
||||
fi
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.foo >config.tar &&
|
||||
d2u_force config.tar &&
|
||||
test_cmp_bin b.tar config.tar &&
|
||||
git archive --format=bar HEAD >config.bar &&
|
||||
tr ab ba <config.bar >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
|
||||
'
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 </dev/null >&3 2>&4 "$*"
|
||||
if test -z "$TEST_NO_REDIRECT"
|
||||
then
|
||||
eval </dev/null >&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
|
||||
;;
|
||||
*)
|
||||
|
||||
Reference in New Issue
Block a user