diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/compiler.h | 41 | ||||
-rw-r--r-- | compat/gmtime.c | 29 | ||||
-rw-r--r-- | compat/mingw.c | 62 | ||||
-rw-r--r-- | compat/regex/regex.c | 1 | ||||
-rw-r--r-- | compat/regex/regex_internal.h | 1 | ||||
-rw-r--r-- | compat/vcbuild/README | 4 | ||||
-rw-r--r-- | compat/win32/path-utils.h | 11 |
7 files changed, 111 insertions, 38 deletions
diff --git a/compat/compiler.h b/compat/compiler.h new file mode 100644 index 0000000000..10dbb65937 --- /dev/null +++ b/compat/compiler.h @@ -0,0 +1,41 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#include "git-compat-util.h" +#include "strbuf.h" + +#ifdef __GLIBC__ +#include <gnu/libc-version.h> +#endif + +static inline void get_compiler_info(struct strbuf *info) +{ + int len = info->len; +#ifdef __clang__ + strbuf_addf(info, "clang: %s\n", __clang_version__); +#elif defined(__GNUC__) + strbuf_addf(info, "gnuc: %d.%d\n", __GNUC__, __GNUC_MINOR__); +#endif + +#ifdef _MSC_VER + strbuf_addf(info, "MSVC version: %02d.%02d.%05d\n", + _MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 100000); +#endif + + if (len == info->len) + strbuf_addstr(info, _("no compiler information available\n")); +} + +static inline void get_libc_info(struct strbuf *info) +{ + int len = info->len; + +#ifdef __GLIBC__ + strbuf_addf(info, "glibc: %s\n", gnu_get_libc_version()); +#endif + + if (len == info->len) + strbuf_addstr(info, _("no libc information available\n")); +} + +#endif /* COMPILER_H */ diff --git a/compat/gmtime.c b/compat/gmtime.c deleted file mode 100644 index e8362dd2b9..0000000000 --- a/compat/gmtime.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "../git-compat-util.h" -#undef gmtime -#undef gmtime_r - -struct tm *git_gmtime(const time_t *timep) -{ - static struct tm result; - return git_gmtime_r(timep, &result); -} - -struct tm *git_gmtime_r(const time_t *timep, struct tm *result) -{ - struct tm *ret; - - memset(result, 0, sizeof(*result)); - ret = gmtime_r(timep, result); - - /* - * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm" - * untouched when it encounters overflow. Since "mday" cannot otherwise - * be zero, we can test this very quickly. - */ - if (ret && !ret->tm_mday) { - ret = NULL; - errno = EOVERFLOW; - } - - return ret; -} diff --git a/compat/mingw.c b/compat/mingw.c index d14065d60e..8ee0b6408e 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -460,8 +460,21 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...) handle = CreateFileW(wfilename, FILE_APPEND_DATA, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, create, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - return errno = err_win_to_posix(GetLastError()), -1; + if (handle == INVALID_HANDLE_VALUE) { + DWORD err = GetLastError(); + + /* + * Some network storage solutions (e.g. Isilon) might return + * ERROR_INVALID_PARAMETER instead of expected error + * ERROR_PATH_NOT_FOUND, which results in an unknown error. If + * so, let's turn the error to ERROR_PATH_NOT_FOUND instead. + */ + if (err == ERROR_INVALID_PARAMETER) + err = ERROR_PATH_NOT_FOUND; + + errno = err_win_to_posix(err); + return -1; + } /* * No O_APPEND here, because the CRT uses it only to reset the @@ -964,7 +977,16 @@ revert_attrs: size_t mingw_strftime(char *s, size_t max, const char *format, const struct tm *tm) { - size_t ret = strftime(s, max, format, tm); + /* a pointer to the original strftime in case we can't find the UCRT version */ + static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime; + size_t ret; + DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t, + const char *, const struct tm *); + + if (INIT_PROC_ADDR(strftime)) + ret = strftime(s, max, format, tm); + else + ret = fallback(s, max, format, tm); if (!ret && errno == EINVAL) die("invalid strftime format: '%s'", format); @@ -1479,6 +1501,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen const char *(*quote_arg)(const char *arg) = is_msys2_sh(cmd ? cmd : *argv) ? quote_arg_msys2 : quote_arg_msvc; + const char *strace_env; /* Make sure to override previous errors, if any */ errno = 0; @@ -1562,6 +1585,31 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen free(quoted); } + strace_env = getenv("GIT_STRACE_COMMANDS"); + if (strace_env) { + char *p = path_lookup("strace.exe", 1); + if (!p) + return error("strace not found!"); + if (xutftowcs_path(wcmd, p) < 0) { + free(p); + return -1; + } + free(p); + if (!strcmp("1", strace_env) || + !strcasecmp("yes", strace_env) || + !strcasecmp("true", strace_env)) + strbuf_insert(&args, 0, "strace ", 7); + else { + const char *quoted = quote_arg(strace_env); + struct strbuf buf = STRBUF_INIT; + strbuf_addf(&buf, "strace -o %s ", quoted); + if (quoted != strace_env) + free((char *)quoted); + strbuf_insert(&args, 0, buf.buf, buf.len); + strbuf_release(&buf); + } + } + ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1)); xutftowcs(wargs, args.buf, 2 * args.len + 1); strbuf_release(&args); @@ -2581,12 +2629,14 @@ not_a_reserved_name: continue; } break; - case 'c': case 'C': /* COM<N>, CON, CONIN$, CONOUT$ */ + case 'c': case 'C': + /* COM1 ... COM9, CON, CONIN$, CONOUT$ */ if ((c = path[++i]) != 'o' && c != 'O') goto not_a_reserved_name; c = path[++i]; - if (c == 'm' || c == 'M') { /* COM<N> */ - if (!isdigit(path[++i])) + if (c == 'm' || c == 'M') { /* COM1 ... COM9 */ + c = path[++i]; + if (c < '1' || c > '9') goto not_a_reserved_name; } else if (c == 'n' || c == 'N') { /* CON */ c = path[i + 1]; diff --git a/compat/regex/regex.c b/compat/regex/regex.c index f3e03a9eab..e6f4a5d177 100644 --- a/compat/regex/regex.c +++ b/compat/regex/regex.c @@ -60,6 +60,7 @@ #undefs RE_DUP_MAX and sets it to the right value. */ #include <limits.h> #include <stdint.h> +#include <stdlib.h> #ifdef GAWK #undef alloca diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h index 3ee8aae59d..0bad8b841e 100644 --- a/compat/regex/regex_internal.h +++ b/compat/regex/regex_internal.h @@ -23,7 +23,6 @@ #include <assert.h> #include <ctype.h> #include <stdio.h> -#include <stdlib.h> #include <string.h> #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC diff --git a/compat/vcbuild/README b/compat/vcbuild/README index 1b6dabf5a2..42292e7c09 100644 --- a/compat/vcbuild/README +++ b/compat/vcbuild/README @@ -92,8 +92,8 @@ The Steps of Build Git with VS2008 the git operations. 3. Inside Git's directory run the command: - make command-list.h - to generate the command-list.h file needed to compile git. + make command-list.h config-list.h + to generate the header file needed to compile git. 4. Then either build Git with the GNU Make Makefile in the Git projects root diff --git a/compat/win32/path-utils.h b/compat/win32/path-utils.h index f2e70872cd..bba2b64408 100644 --- a/compat/win32/path-utils.h +++ b/compat/win32/path-utils.h @@ -20,6 +20,17 @@ static inline char *win32_find_last_dir_sep(const char *path) return ret; } #define find_last_dir_sep win32_find_last_dir_sep +static inline int win32_has_dir_sep(const char *path) +{ + /* + * See how long the non-separator part of the given path is, and + * if and only if it covers the whole path (i.e. path[len] is NUL), + * there is no separator in the path---otherwise there is a separator. + */ + size_t len = strcspn(path, "/\\"); + return !!path[len]; +} +#define has_dir_sep(path) win32_has_dir_sep(path) int win32_offset_1st_component(const char *path); #define offset_1st_component win32_offset_1st_component |