diff --git a/builtin/rebase.c b/builtin/rebase.c index eef6b3836aa4c1..1ce0b3d0245a5c 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -360,13 +360,6 @@ static void add_var(struct strbuf *buf, const char *name, const char *value) } } -static const char *resolvemsg = -N_("Resolve all conflicts manually, mark them as resolved with\n" -"\"git add/rm \", then run \"git rebase --continue\".\n" -"You can instead skip this commit: run \"git rebase --skip\".\n" -"To abort and get back to the state before \"git rebase\", run " -"\"git rebase --abort\"."); - #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION" #define RESET_HEAD_DETACH (1<<0) @@ -485,7 +478,6 @@ static int reset_head(struct object_id *oid, const char *action, return ret; } - static int move_to_original_branch(struct rebase_options *opts) { struct strbuf buf = STRBUF_INIT; @@ -502,6 +494,13 @@ static int move_to_original_branch(struct rebase_options *opts) return ret; } +static const char *resolvemsg = +N_("Resolve all conflicts manually, mark them as resolved with\n" +"\"git add/rm \", then run \"git rebase --continue\".\n" +"You can instead skip this commit: run \"git rebase --skip\".\n" +"To abort and get back to the state before \"git rebase\", run " +"\"git rebase --abort\"."); + static int run_am(struct rebase_options *opts) { struct child_process am = CHILD_PROCESS_INIT; diff --git a/compat/mingw.c b/compat/mingw.c index 1ecacb0fa770be..d5e28ce356ddae 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -8,9 +8,9 @@ #include "../cache.h" #include "win32/exit-process.h" #include "win32/lazyload.h" -#include "../string-list.h" -#include "../attr.h" #include "../config.h" +#include "../attr.h" +#include "../string-list.h" #define HCAST(type, handle) ((type)(intptr_t)handle) @@ -956,6 +956,7 @@ int (*lstat)(const char *file_name, struct stat *buf) = mingw_lstat; static int get_file_info_by_handle(HANDLE hnd, struct stat *buf) { BY_HANDLE_FILE_INFORMATION fdata; + if (!GetFileInformationByHandle(hnd, &fdata)) { errno = err_win_to_posix(GetLastError()); return -1; @@ -2002,70 +2003,6 @@ int mingw_kill(pid_t pid, int sig) return -1; } -#if defined(_MSC_VER) - -/* UTF8 versions of getenv and putenv (and unsetenv). - * Internally, they use the CRT's stock UNICODE routines - * to avoid data loss. - * - * Unlike the mingw version, we DO NOT directly write to - * the CRT variables. We also DO NOT try to manage/replace - * the CRT storage. - */ -char *msc_getenv(const char *name) -{ - int len_key, len_value; - wchar_t *w_key; - char *value; - const wchar_t *w_value; - - if (!name || !*name) - return NULL; - - len_key = strlen(name) + 1; - w_key = calloc(len_key, sizeof(wchar_t)); - xutftowcs(w_key, name, len_key); - w_value = _wgetenv(w_key); - free(w_key); - - if (!w_value) - return NULL; - - len_value = wcslen(w_value) * 3 + 1; - value = calloc(len_value, sizeof(char)); - xwcstoutf(value, w_value, len_value); - - /* TODO Warning: We return "value" which is an allocated - * value and the caller is NOT expecting to have to free - * it, so we leak memory. - */ - return value; -} - -int msc_putenv(const char *name) -{ - int len, result; - char *equal; - wchar_t *wide; - - if (!name || !*name) - return 0; - - len = strlen(name); - equal = strchr(name, '='); - wide = calloc(len+1+!equal, sizeof(wchar_t)); - xutftowcs(wide, name, len+1); - if (!equal) - wcscat(wide, L"="); - - result = _wputenv(wide); - - free(wide); - return result; -} - -#else - /* * UTF-8 versions of getenv(), putenv() and unsetenv(). * Internally, they use the CRT's stock UNICODE routines @@ -2146,14 +2083,10 @@ int mingw_putenv(const char *namevalue) return result ? 0 : -1; } -#endif - - static void ensure_socket_initialization(void) { WSADATA wsa; static int initialized = 0; - if (initialized) return; @@ -2161,7 +2094,7 @@ static void ensure_socket_initialization(void) if (WSAStartup(MAKEWORD(2,2), &wsa)) die("unable to initialize winsock subsystem, error %d", WSAGetLastError()); - + atexit((void(*)(void)) WSACleanup); initialized = 1; } @@ -3051,13 +2984,6 @@ int handle_long_path(wchar_t *path, int len, int max_path, int expand) * mingw startup code, see init.c in mingw runtime). */ int _CRT_glob = 0; - -typedef struct { - int newmode; -} _startupinfo; - -extern int __wgetmainargs(int *argc, wchar_t ***argv, wchar_t ***env, int glob, - _startupinfo *si); #endif static NORETURN void die_startup(void) @@ -3151,7 +3077,6 @@ static void adjust_symlink_flags(void) symlink_file_flags |= 2; symlink_directory_flags |= 2; } - } static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type) diff --git a/compat/win32/fscache.c b/compat/win32/fscache.c index 8833a5e00d305d..9c62a0a1429a44 100644 --- a/compat/win32/fscache.c +++ b/compat/win32/fscache.c @@ -384,6 +384,7 @@ int fscache_enable(size_t initial_size) * any threads are using the fscache. */ if (!initialized) { + InitializeCriticalSection(&mutex); if (!dwTlsIndex) { dwTlsIndex = TlsAlloc(); if (dwTlsIndex == TLS_OUT_OF_INDEXES) diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index 11383eb5f4d823..c6cb8dd2190062 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -34,17 +34,6 @@ typedef int pthread_mutexattr_t; #define pthread_cond_t CONDITION_VARIABLE -WINBASEAPI VOID WINAPI -InitializeConditionVariable(PCONDITION_VARIABLE ConditionVariable); -WINBASEAPI VOID WINAPI -WakeConditionVariable(PCONDITION_VARIABLE ConditionVariable); -WINBASEAPI VOID WINAPI -WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable); -WINBASEAPI BOOL WINAPI -SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, - PCRITICAL_SECTION CriticalSection, - DWORD dwMilliseconds); - #define pthread_cond_init(a,b) InitializeConditionVariable((a)) #define pthread_cond_destroy(a) do {} while (0) #define pthread_cond_wait(a,b) return_0(SleepConditionVariableCS((a), (b), INFINITE)) diff --git a/config.c b/config.c index 1a0e950c3ca363..790a4547d7731e 100644 --- a/config.c +++ b/config.c @@ -1669,7 +1669,7 @@ static int do_git_config_sequence(const struct config_options *opts, if (opts->commondir) repo_config = mkpathdup("%s/config", opts->commondir); else if (opts->git_dir) - repo_config = mkpathdup("%s/config", opts->git_dir); + BUG("git_dir without commondir"); else repo_config = NULL; diff --git a/config.mak.uname b/config.mak.uname index c820bc90458b8e..fa44d2bfe869ae 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -584,7 +584,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) ETAGS_TARGET = ETAGS NO_POSIX_GOODIES = UnfortunatelyYes DEFAULT_HELP_FORMAT = html - BASIC_LDFLAGS += -municode + BASIC_LDFLAGS += -municode -mconsole COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\" COMPAT_OBJS += compat/mingw.o compat/winansi.o \ diff --git a/git-compat-util.h b/git-compat-util.h index fb0da4957429b2..2d1634611ef697 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -281,33 +281,6 @@ extern char *gitdirname(char *); #ifndef NO_ICONV #include -#ifdef _MSC_VER -/* - * At least version 1.14.0.11 of the libiconv NuPkg at - * https://www.nuget.org/packages/libiconv/ does not set errno at all. - * - * Let's simulate it by testing whether we might have possibly run out of - * space. - */ -static inline size_t msvc_iconv(iconv_t conv, - const char **inpos, size_t *insize, - char **outpos, size_t *outsize) -{ - int saved_errno = errno; - size_t res; - - errno = ENOENT; - res = iconv(conv, inpos, insize, outpos, outsize); - if (!res) - errno = saved_errno; - else if (errno == ENOENT) - errno = *outsize < 16 ? E2BIG : 0; - - return res; -} -#undef iconv -#define iconv msvc_iconv -#endif #endif #ifndef NO_OPENSSL diff --git a/http.c b/http.c index 0ebf8f77a6d20b..43e75ac583b428 100644 --- a/http.c +++ b/http.c @@ -835,7 +835,7 @@ static CURL *get_curl_handle(void) curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE); #else warning("CURLSSLOPT_NO_REVOKE not applied to curl SSL options because\n" - "your curl version is too old (>= 7.44.0)"); + "your curl version is too old (< 7.44.0)"); #endif } diff --git a/t/test-lib.sh b/t/test-lib.sh index 72604ec4fb2e53..8f92b8addc63b5 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -68,10 +68,15 @@ export PERL_PATH SHELL_PATH ################################################################ # It appears that people try to run tests without building... -test -n "$GIT_TEST_INSTALLED" || "$GIT_BUILD_DIR/git$X" >/dev/null || +"${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null if test $? != 1 then - echo >&2 'error: you do not seem to have built git yet.' + if test -n "$GIT_TEST_INSTALLED" + then + echo >&2 "error: there is no working Git at '$GIT_TEST_INSTALLED'" + else + echo >&2 'error: you do not seem to have built git yet.' + fi exit 1 fi