From e7cf4e94c6f147953af4d079ca2e9ef0d7a29ae9 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 28 Dec 2009 18:04:21 +0100 Subject: [PATCH 01/15] MinGW: Use pid_t more consequently, introduce uid_t for greater compatibility Signed-off-by: Sebastian Schuberth --- compat/mingw.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compat/mingw.h b/compat/mingw.h index 3b2477be5f..912c4256fd 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -6,6 +6,7 @@ */ typedef int pid_t; +typedef int uid_t; #define hstrerror strerror #define S_IFLNK 0120000 /* Symbolic link */ @@ -75,17 +76,17 @@ 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; } -static inline int fork(void) +static inline pid_t fork(void) { errno = ENOSYS; return -1; } static inline unsigned int alarm(unsigned int seconds) { return 0; } static inline int fsync(int fd) { return _commit(fd); } -static inline int getppid(void) +static inline pid_t getppid(void) { return 1; } static inline void sync(void) {} -static inline int getuid() +static inline uid_t getuid(void) { return 1; } static inline struct passwd *getpwnam(const char *name) { return NULL; } @@ -117,7 +118,7 @@ static inline int mingw_unlink(const char *pathname) } #define unlink mingw_unlink -static inline int waitpid(pid_t pid, int *status, unsigned options) +static inline pid_t waitpid(pid_t pid, int *status, unsigned options) { if (options == 0) return _cwait(status, pid, 0); @@ -158,7 +159,7 @@ int poll(struct pollfd *ufds, unsigned int nfds, int timeout); struct tm *gmtime_r(const time_t *timep, struct tm *result); struct tm *localtime_r(const time_t *timep, struct tm *result); int getpagesize(void); /* defined in MinGW's libgcc.a */ -struct passwd *getpwuid(int uid); +struct passwd *getpwuid(uid_t uid); int setitimer(int type, struct itimerval *in, struct itimerval *out); int sigaction(int sig, struct sigaction *in, struct sigaction *out); int link(const char *oldpath, const char *newpath); From 4091bfc9616d5ac0371bb2ed80558f4a8f4d12f5 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 28 Dec 2009 18:13:52 +0100 Subject: [PATCH 02/15] MinGW: Add missing file mode bit defines Signed-off-by: Sebastian Schuberth --- compat/mingw.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compat/mingw.h b/compat/mingw.h index 912c4256fd..74c799ad38 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -12,12 +12,24 @@ typedef int uid_t; #define S_IFLNK 0120000 /* Symbolic link */ #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) #define S_ISSOCK(x) 0 + +#ifndef _STAT_H_ +#define S_IRUSR 0 +#define S_IWUSR 0 +#define S_IXUSR 0 +#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif #define S_IRGRP 0 #define S_IWGRP 0 #define S_IXGRP 0 -#define S_ISGID 0 +#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) #define S_IROTH 0 +#define S_IWOTH 0 #define S_IXOTH 0 +#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#define S_ISUID 0 +#define S_ISGID 0 +#define S_ISVTX 0 #define WIFEXITED(x) 1 #define WIFSIGNALED(x) 0 From 9b9784cab9bba925ab35c7aa8d4e5967a4268093 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Wed, 17 Mar 2010 15:17:34 +0000 Subject: [PATCH 03/15] MinGW: fix stat() and lstat() implementations for handling symlinks In msysGit the stat() function has been implemented using mingw_lstat which sets the st_mode member to S_IFLNK when a symbolic links is found. This causes the is_executable function to return when git attempts to build a list of available commands in the help code and we end up missing most git commands. (msysGit issue #445) This patch modifies the implementation so that lstat() will return the link flag but if we are called as stat() we read the size of the target and set the mode to that of a regular file. Includes squashed fix st_mode for symlink dirs Signed-off-by: Pat Thoyts Signed-off-by: Erik Faye-Lund --- compat/mingw.c | 39 +++++++++++++++++++++++++++++++++++---- compat/mingw.h | 3 ++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index f2d9e1fd97..ee8f3be5b2 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -192,8 +192,11 @@ static inline time_t filetime_to_time_t(const FILETIME *ft) /* We keep the do_lstat code in a separate function to avoid recursion. * When a path ends with a slash, the stat will fail with ENOENT. In * this case, we strip the trailing slashes and stat again. + * + * If follow is true then act like stat() and report on the link + * target. Otherwise report on the link itself. */ -static int do_lstat(const char *file_name, struct stat *buf) +static int do_lstat(int follow, const char *file_name, struct stat *buf) { WIN32_FILE_ATTRIBUTE_DATA fdata; @@ -209,6 +212,25 @@ static int do_lstat(const char *file_name, struct stat *buf) buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime)); buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime)); buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime)); + if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + WIN32_FIND_DATAA findbuf; + HANDLE handle = FindFirstFileA(file_name, &findbuf); + if (handle != INVALID_HANDLE_VALUE) { + if ((findbuf.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && + (findbuf.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) { + if (follow) { + char buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + buf->st_size = readlink(file_name, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE); + } else { + buf->st_mode = S_IFLNK; + } + buf->st_mode |= S_IREAD; + if (!(findbuf.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) + buf->st_mode |= S_IWRITE; + } + FindClose(handle); + } + } return 0; } return -1; @@ -220,12 +242,12 @@ static int do_lstat(const char *file_name, struct stat *buf) * complete. Note that Git stat()s are redirected to mingw_lstat() * too, since Windows doesn't really handle symlinks that well. */ -int mingw_lstat(const char *file_name, struct stat *buf) +static int do_stat_internal(int follow, const char *file_name, struct stat *buf) { int namelen; static char alt_name[PATH_MAX]; - if (!do_lstat(file_name, buf)) + if (!do_lstat(follow, file_name, buf)) return 0; /* if file_name ended in a '/', Windows returned ENOENT; @@ -244,7 +266,16 @@ int mingw_lstat(const char *file_name, struct stat *buf) memcpy(alt_name, file_name, namelen); alt_name[namelen] = 0; - return do_lstat(alt_name, buf); + return do_lstat(follow, alt_name, buf); +} + +int mingw_lstat(const char *file_name, struct stat *buf) +{ + return do_stat_internal(0, file_name, buf); +} +int mingw_stat(const char *file_name, struct stat *buf) +{ + return do_stat_internal(1, file_name, buf); } #undef fstat diff --git a/compat/mingw.h b/compat/mingw.h index 74c799ad38..47839663be 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -235,10 +235,11 @@ int mingw_getpagesize(void); #ifndef ALREADY_DECLARED_STAT_FUNCS #define stat _stati64 int mingw_lstat(const char *file_name, struct stat *buf); +int mingw_stat(const char *file_name, struct stat *buf); int mingw_fstat(int fd, struct stat *buf); #define fstat mingw_fstat #define lstat mingw_lstat -#define _stati64(x,y) mingw_lstat(x,y) +#define _stati64(x,y) mingw_stat(x,y) #endif int mingw_utime(const char *file_name, const struct utimbuf *times); From 442dada22d3b6e511d30b05a80bab153619e52a7 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Thu, 18 Mar 2010 21:45:19 +0000 Subject: [PATCH 04/15] MinGW: Report errors when failing to launch the html browser. The mingw function to launch the system html browser is silent if the target file does not exist leaving the user confused. Make it display something. Signed-off-by: Pat Thoyts Reviewed-by: Erik Faye-Lund --- compat/mingw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index ee8f3be5b2..431e32265d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1417,6 +1417,7 @@ void mingw_open_html(const char *unixpath) const char *, const char *, const char *, INT); T ShellExecute; HMODULE shell32; + int r; shell32 = LoadLibrary("shell32.dll"); if (!shell32) @@ -1426,9 +1427,12 @@ void mingw_open_html(const char *unixpath) die("cannot run browser"); printf("Launching default browser to display HTML ...\n"); - ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0); - + r = (int)ShellExecute(NULL, "open", htmlpath, NULL, "\\", SW_SHOWNORMAL); FreeLibrary(shell32); + /* see the MSDN documentation referring to the result codes here */ + if (r <= 32) { + die("failed to launch browser for %.*s", MAX_PATH, unixpath); + } } int link(const char *oldpath, const char *newpath) From 4e57bafe8bc60e35b9841b22f99882581c466daf Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 12 Jun 2010 00:45:35 +0200 Subject: [PATCH 05/15] merge-octopus: Work around environment issue on Windows For some reason, the environment variables get upper-cased when a subprocess is launched on Windows. Cope with that. [PT: fixed typo in the char range noted by junio] Signed-off-by: Johannes Schindelin Signed-off-by: Pat Thoyts --- git-merge-octopus.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh index 615753c83c..8643f74cb0 100755 --- a/git-merge-octopus.sh +++ b/git-merge-octopus.sh @@ -61,6 +61,11 @@ do esac eval pretty_name=\${GITHEAD_$SHA1:-$SHA1} + if test "$SHA1" = "$pretty_name" + then + SHA1_UP="$(echo "$SHA1" | tr a-z A-Z)" + eval pretty_name=\${GITHEAD_$SHA1_UP:-$pretty_name} + fi common=$(git merge-base --all $SHA1 $MRC) || die "Unable to find common commit with $pretty_name" From 3ba9ba8f34eda286867fba37e496850dc109af74 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Mon, 27 Sep 2010 22:02:57 +0100 Subject: [PATCH 06/15] Skip t1300.70 and 71 on msysGit. These two tests fail on msysGit because /dev/null is an alias for nul on Windows and when reading the value back from git config the alias does not match the real filename. Also the HOME environment variable has a unix-style path but git returns a native equivalent path for '~'. As these are platform-dependent equivalent results it seems simplest to skip the test entirely. Moves the NOT_MINGW prereq from t5503 into the test library. Signed-off-by: Pat Thoyts --- t/t1300-repo-config.sh | 6 +++--- t/t5503-tagfollow.sh | 9 ++------- t/test-lib.sh | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 074f2f2e3e..d0ab8ffe1b 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -701,13 +701,13 @@ cat >expect <<\EOF trailingtilde = foo~ EOF -test_expect_success 'set --path' ' +test_expect_success NOT_MINGW 'set --path' ' git config --path path.home "~/" && git config --path path.normal "/dev/null" && git config --path path.trailingtilde "foo~" && test_cmp expect .git/config' -if test "${HOME+set}" +if test_have_prereq NOT_MINGW && test "${HOME+set}" then test_set_prereq HOMEVAR fi @@ -730,7 +730,7 @@ cat >expect <<\EOF foo~ EOF -test_expect_success 'get --path copes with unset $HOME' ' +test_expect_success NOT_MINGW 'get --path copes with unset $HOME' ' ( unset HOME; test_must_fail git config --get --path path.home \ diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh index 8a298a655f..b6b1fc30cd 100755 --- a/t/t5503-tagfollow.sh +++ b/t/t5503-tagfollow.sh @@ -4,14 +4,9 @@ test_description='test automatic tag following' . ./test-lib.sh -case $(uname -s) in -*MINGW*) +if !test_have_prereq NOT_MINGW; then say "GIT_DEBUG_SEND_PACK not supported - skipping tests" - ;; -*) - test_set_prereq NOT_MINGW - ;; -esac +fi # End state of the repository: # diff --git a/t/test-lib.sh b/t/test-lib.sh index 830e5e7360..a85e7954ad 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -975,6 +975,7 @@ case $(uname -s) in test_set_prereq POSIXPERM test_set_prereq BSLASHPSPEC test_set_prereq EXECKEEPSPID + test_set_prereq NOT_MINGW ;; esac From a94114ad3d0fc584dea3ecd508135307882066a9 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sun, 12 Sep 2010 10:37:24 +0100 Subject: [PATCH 07/15] Do not strip CR when grepping HTTP headers. By default, MSYS grep reads in text-mode and converts CRLF into LF line endings. For testing HTTP use binary mode (-U) as checking is done for CR in HTTP headers Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts --- t/t5560-http-backend-noserver.sh | 2 ++ t/test-lib.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index 44885b850c..4b0364374d 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -5,6 +5,8 @@ test_description='test git-http-backend-noserver' HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY" +test_have_prereq MINGW && export GREP_OPTIONS=-U + run_backend() { echo "$2" | QUERY_STRING="${1#*\?}" \ diff --git a/t/test-lib.sh b/t/test-lib.sh index a85e7954ad..2af8f10c83 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -970,6 +970,7 @@ case $(uname -s) in # no POSIX permissions # backslashes in pathspec are converted to '/' # exec does not inherit the PID + test_set_prereq MINGW ;; *) test_set_prereq POSIXPERM From 97f2c33a52d2c33d6f6c8569e875fde0ef18e2e2 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 17 Sep 2010 14:27:56 +0100 Subject: [PATCH 08/15] Skip 'git archive --remote' test on msysGit This test requires git daemon support which is not available on msysgit Signed-off-by: Pat Thoyts --- t/t5000-tar-tree.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index 27bfba55bd..cff1b3e050 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -94,7 +94,7 @@ test_expect_success 'git archive with --output' \ 'git archive --output=b4.tar HEAD && test_cmp b.tar b4.tar' -test_expect_success 'git archive --remote' \ +test_expect_success NOT_MINGW 'git archive --remote' \ 'git archive --remote=. HEAD >b5.tar && test_cmp b.tar b5.tar' From ca02ad3447efdbd4cb2aa9ba0ee3fc6124035274 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Fri, 17 Sep 2010 09:16:01 -0400 Subject: [PATCH 09/15] Side-step sed line-ending "corruption" leading to t6038 failure. By default, MSYS sed throws away CR from CRLF line-endings. Tests t6038.5 and t6038.6 employ sed to normalize conflict output of git-merge for validation purposes. These tests expect CRLF line-endings to be present in the normalized output of git-merge, and thus fail when sed undesirably removes CR. Fix by employing sed's -b/--binary switch to suppress its default behavior of dropping CR characters. Acked-by: Johannes Sixt Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts --- t/t6038-merge-text-auto.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh index 52d0dc4bb8..460bf741b5 100755 --- a/t/t6038-merge-text-auto.sh +++ b/t/t6038-merge-text-auto.sh @@ -14,6 +14,8 @@ test_description='CRLF merge conflict across text=auto change . ./test-lib.sh +test_have_prereq MINGW && SED_OPTIONS=-b + test_expect_success setup ' git config core.autocrlf false && @@ -60,7 +62,7 @@ test_expect_success setup ' test_expect_success 'set up fuzz_conflict() helper' ' fuzz_conflict() { - sed -e "s/^\([<>=]......\) .*/\1/" "$@" + sed $SED_OPTIONS -e "s/^\([<>=]......\) .*/\1/" "$@" } ' From 36e035f5dcd214039d5ea96c29de110ae7435137 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 20 Jul 2010 19:29:16 -0400 Subject: [PATCH 10/15] Side-step MSYS-specific path "corruption" leading to t5560 failure. Upon program invocation, MSYS converts environment variables containing path-like values from Unix-style to DOS-style under the assumption that the program being invoked understands only DOS-style pathnames. For instance, the Unix-style path /msysgit is translated to c:/msysgit. For test t5560, the path being requested from git-http-backend is specified via environment variable PATH_INFO as a URL path of the form /repo.git/foobar, which git-http-backend combines with GIT_PROJECT_ROOT to determine the actual physical path within the repository. This is a case where MSYS's conversion of the path-like value of PATH_INFO causes harm, for two reasons. First, the resulting converted path, when joined with GIT_PROJECT_ROOT is bogus (for instance, "C:/msysgit/git/t/trash-zzz/C:/msysgit/repo.git/HEAD"). Second, the converted PATH_INFO path is rejected by git-http-backend as an 'alias' due to validation failure on the part of daemon_avoid_alias(). Unfortunately, the standard work-around of doubling the leading slash (i.e. //repo.git/foobar) to suppress MSYS path conversion works only for command-line arguments, but not for environment variables. Consequently, side step the problem by instead passing git-http-backend an already-constructed full path rather than components GIT_PROJECT_ROOT and PATH_INFO. Acked-by: Johannes Sixt Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts --- t/t5560-http-backend-noserver.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index 4b0364374d..406432e7a5 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -10,8 +10,7 @@ test_have_prereq MINGW && export GREP_OPTIONS=-U run_backend() { echo "$2" | QUERY_STRING="${1#*\?}" \ - GIT_PROJECT_ROOT="$HTTPD_DOCUMENT_ROOT_PATH" \ - PATH_INFO="${1%%\?*}" \ + PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%\?*}" \ git http-backend >act.out 2>act.err } From 5e9677cbdf1840836e22d9cf23198de34877e283 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Thu, 30 Sep 2010 14:24:07 +0100 Subject: [PATCH 11/15] git-am: fix detection of absolute paths for windows Add an is_absolute_path function to abstract out platform differences in checking for an absolute or relative path. Specifically fixes t4150-am on Windows. [PT: updated following suggestion from j6t to support \* and //*] Signed-off-by: Johannes Sixt Signed-off-by: Pat Thoyts --- git-am.sh | 12 ++++++------ git-sh-setup.sh | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/git-am.sh b/git-am.sh index e7f008c7ba..9317b38935 100755 --- a/git-am.sh +++ b/git-am.sh @@ -444,12 +444,12 @@ else set x first= } - case "$arg" in - /*) - set "$@" "$arg" ;; - *) - set "$@" "$prefix$arg" ;; - esac + if is_absolute_path "$arg" + then + set "$@" "$arg" + else + set "$@" "$prefix$arg" + fi done shift fi diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 6131670860..58d30c9388 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -209,5 +209,20 @@ case $(uname -s) in find () { /usr/bin/find "$@" } + is_absolute_path () { + case "$1" in + [/\\]* | [A-Za-z]:*) + return 0 ;; + esac + return 1 + } ;; +*) + is_absolute_path () { + case "$1" in + /*) + return 0 ;; + esac + return 1 + } esac From 1a4042096c2e8893246a99ef8e43c07acb76f54b Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 23 Sep 2010 17:35:25 +0000 Subject: [PATCH 12/15] mingw: do not crash on open(NULL, ...) fetch_and_setup_pack_index() apparently pass a NULL-pointer to parse_pack_index(), which in turn pass it to check_packed_git_idx(), which again pass it to open(). Since open() already sets errno correctly for the NULL-case, let's just avoid the problematic strcmp. [PT: squashed in fix for fopen which was missed first time round] Acked-by: Johannes Sixt Signed-off-by: Erik Faye-Lund Signed-off-by: Pat Thoyts --- compat/mingw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 431e32265d..bd1403a1d5 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -127,7 +127,7 @@ int mingw_open (const char *filename, int oflags, ...) mode = va_arg(args, int); va_end(args); - if (!strcmp(filename, "/dev/null")) + if (filename && !strcmp(filename, "/dev/null")) filename = "nul"; fd = open(filename, oflags, mode); @@ -160,7 +160,7 @@ ssize_t mingw_write(int fd, const void *buf, size_t count) #undef fopen FILE *mingw_fopen (const char *filename, const char *otype) { - if (!strcmp(filename, "/dev/null")) + if (filename && !strcmp(filename, "/dev/null")) filename = "nul"; return fopen(filename, otype); } From b248e950966769f5f981321ea9d12f2b238c978c Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 6 Jul 2010 21:48:47 -0400 Subject: [PATCH 13/15] Fix 'clone' failure at DOS root directory. Cloning via relative path fails for a project residing immediately under the root directory of a DOS drive. For instance, for project c:/foo, issuing "cd c:/" followed by "git clone foo bar" fails with error "Unable to find remote helper for 'c'". The problem is caused by make_nonrelative_path() incorrectly returning c://foo rather than c:/foo for input "foo". The bogus path c://foo is misinterpreted by transport_get() as a URL with unrecognized protocol "c", hence the missing remote helper error. Fix make_nonrelative_path() to return c:/foo rather than c://foo (and /foo rather than //foo on Unix). Resolves msysgit issue #501 [1] [PT: squashed in changes requested by Junio [2][3]] [1] http://code.google.com/p/msysgit/issues/detail?id=501 [2] http://marc.info/?l=git&m=128570102331652&w=2 [3] http://marc.info/?l=git&m=128573246704862&w=2 Acked-by: Johannes Sixt Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts Signed-off-by: Johannes Schindelin --- abspath.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/abspath.c b/abspath.c index c91a29cb29..91ca00f05f 100644 --- a/abspath.c +++ b/abspath.c @@ -108,10 +108,14 @@ const char *make_nonrelative_path(const char *path) if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) die("Too long path: %.*s", 60, path); } else { + size_t len; + const char *fmt; const char *cwd = get_pwd_cwd(); if (!cwd) die_errno("Cannot determine the current working directory"); - if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX) + len = strlen(cwd); + fmt = (len > 0 && is_dir_sep(cwd[len-1])) ? "%s%s" : "%s/%s"; + if (snprintf(buf, PATH_MAX, fmt, cwd, path) >= PATH_MAX) die("Too long path: %.*s", 60, path); } return buf; From 77df1f1edfab61bf605f707aeb3b5f5bd54ffb76 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 27 Sep 2010 07:01:59 -0400 Subject: [PATCH 14/15] Fix Windows-specific macro redefinition warning. shell.c defines macro HELP_COMMAND which collides with a like-named macro from winuser.h. Avoid collision by sanitizing preprocessor namespace after including Windows headers. Acked-by: Johannes Schindelin Acked-by: Johannes Sixt Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts --- compat/mingw.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compat/mingw.h b/compat/mingw.h index 47839663be..a2213b3911 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -78,6 +78,12 @@ struct itimerval { }; #define ITIMER_REAL 0 +/* + * sanitize preprocessor namespace polluted by Windows headers defining + * macros which collide with git local versions + */ +#undef HELP_COMMAND /* from winuser.h */ + /* * trivial stubs */ From 5debf9a5ac89e9ba49dedc960078cf22bba25c50 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 27 Sep 2010 07:02:17 -0400 Subject: [PATCH 15/15] Add MinGW-specific execv() override. As of 2dbc887e, shell.c employs execv(), so provide a MinGW-specific mingw_execv() override, complementing existing mingw_execvp() and cousins. As a bonus, this also resolves a compilation warning due to an execv() prototype mismatch between Linux and MinGW. Linux expects the second argument to be (char *const *), whereas MinGW expects (const char *const *). Acked-by: Johannes Schindelin Acked-by: Johannes Sixt Signed-off-by: Eric Sunshine Signed-off-by: Pat Thoyts --- compat/mingw.c | 5 +++++ compat/mingw.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index bd1403a1d5..6590f33cc8 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -904,6 +904,11 @@ void mingw_execvp(const char *cmd, char *const *argv) free_path_split(path); } +void mingw_execv(const char *cmd, char *const *argv) +{ + mingw_execve(cmd, argv, environ); +} + static char **copy_environ(void) { char **env; diff --git a/compat/mingw.h b/compat/mingw.h index a2213b3911..83e35e833b 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -256,6 +256,8 @@ pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env, int fhin, int fhout, int fherr); void mingw_execvp(const char *cmd, char *const *argv); #define execvp mingw_execvp +void mingw_execv(const char *cmd, char *const *argv); +#define execv mingw_execv static inline unsigned int git_ntohl(unsigned int x) { return (unsigned int)ntohl(x); }