From e7f1e880224cee823ffc2119c1314b0de3b28cf5 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 28 Apr 2014 18:29:05 +0200 Subject: [PATCH 1/7] Makefile: do not depend on curl-config MinGW builds of cURL does not ship with curl-config unless built with the autoconf based build system, which is not the practice recommended by the documentation. MsysGit has had issues with binaries of that sort, so it has switched away from autoconf-based cURL-builds. Unfortunately, broke pushing over WebDAV on Windows, because http-push.c depends on cURL's multi-threaded API, which we could not determine the presence of any more. Since troublesome curl-versions are ancient, and not even present in RedHat 5, let's just assume cURL is capable instead of doing a non-robust check. Instead, add a check for curl_multi_init to our configure-script, for those on ancient system. They probably already need to do the configure-dance anyway. Signed-off-by: Erik Faye-Lund --- Makefile | 7 ++----- configure.ac | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8c3c724a7f..a327c63330 100644 --- a/Makefile +++ b/Makefile @@ -1059,14 +1059,11 @@ else REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES) PROGRAM_OBJS += http-fetch.o PROGRAMS += $(REMOTE_CURL_NAMES) - curl_check := $(shell (echo 070908; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p) - ifeq "$(curl_check)" "070908" + ifndef NO_CURL_MULTI ifndef NO_EXPAT PROGRAM_OBJS += http-push.o endif - endif - curl_check := $(shell (echo 072200; curl-config --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p) - ifeq "$(curl_check)" "072200" + # Assume that cURL is new enough USE_CURL_FOR_IMAP_SEND = YesPlease endif ifdef USE_CURL_FOR_IMAP_SEND diff --git a/configure.ac b/configure.ac index 14012fad72..8bc0677159 100644 --- a/configure.ac +++ b/configure.ac @@ -521,6 +521,17 @@ AC_CHECK_LIB([curl], [curl_global_init], [NO_CURL=], [NO_CURL=YesPlease]) +if test -z "$NO_CURL"; then + +AC_CHECK_DECLS([curl_multi_init], +[NO_CURL_MULTI=], +[NO_CURL_MULTI=UnfortunatelyYes], +[[#include ]]) + +GIT_CONF_SUBST([NO_CURL_MULTI]) + +fi + GIT_UNSTASH_FLAGS($CURLDIR) GIT_CONF_SUBST([NO_CURL]) From 50cded246d61881200eb4637e8549ec32444df32 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 24 Feb 2015 13:07:10 -0600 Subject: [PATCH 2/7] Only use CURLOPT_LOGIN_OPTIONS if it is actually available This fixes the compilation on an older Linux that was used to debug test failures when upgrading Git for Windows to Git v2.3.0. Signed-off-by: Johannes Schindelin --- imap-send.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imap-send.c b/imap-send.c index 37ac4aa86a..8c3fc212ba 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1422,11 +1422,15 @@ static CURL *setup_curl(struct imap_server_conf *srvc) curl_easy_setopt(curl, CURLOPT_PORT, server.port); if (server.auth_method) { +#if LIBCURL_VERSION_NUM < 0x072200 + warning("No LOGIN_OPTIONS support in this cURL version"); +#else struct strbuf auth = STRBUF_INIT; strbuf_addstr(&auth, "AUTH="); strbuf_addstr(&auth, server.auth_method); curl_easy_setopt(curl, CURLOPT_LOGIN_OPTIONS, auth.buf); strbuf_release(&auth); +#endif } if (!server.use_ssl) From 54875eb33c36124b5a67f8b0481c3e8226cec5c6 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Sat, 28 Feb 2015 23:59:04 +0100 Subject: [PATCH 3/7] remote-http(s): Support SOCKS proxies With this patch we properly support SOCKS proxies, configured e.g. like this: git config http.proxy socks5://192.168.67.1:32767 Without this patch, Git mistakenly tries to use SOCKS proxies as if they were HTTP proxies, resulting in a error message like: fatal: unable to access 'http://.../': Proxy CONNECT aborted This patch was required to work behind a faulty AP and scraped from http://stackoverflow.com/questions/15227130/#15228479 and guarded with an appropriate cURL version check by Johannes Schindelin. Signed-off-by: Johannes Schindelin --- http.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http.c b/http.c index e9c6fdd835..e7e3c33304 100644 --- a/http.c +++ b/http.c @@ -416,6 +416,17 @@ static CURL *get_curl_handle(void) if (curl_http_proxy) { curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy); +#if LIBCURL_VERSION_NUM >= 0x071800 + if (starts_with(curl_http_proxy, "socks5")) + curl_easy_setopt(result, + CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + else if (starts_with(curl_http_proxy, "socks4a")) + curl_easy_setopt(result, + CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A); + else if (starts_with(curl_http_proxy, "socks")) + curl_easy_setopt(result, + CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); +#endif } #if LIBCURL_VERSION_NUM >= 0x070a07 curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY); From 3aa1da35ece8a52740217b93459e30376183f9c7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 24 Feb 2015 19:20:13 +0000 Subject: [PATCH 4/7] Facilitate debugging Git executables in tests with gdb When prefixing a Git call in the test suite with 'TEST_GDB_GIT=1 ', it will now be run with GDB, allowing the developer to debug test failures more conveniently. Signed-off-by: Johannes Schindelin --- wrap-for-bin.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh index 701d2339b9..a151c95d4c 100644 --- a/wrap-for-bin.sh +++ b/wrap-for-bin.sh @@ -19,4 +19,11 @@ GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale' PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH" export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR +if test -n "$TEST_GDB_GIT" +then + exec gdb -args "${GIT_EXEC_PATH}/@@PROG@@" "$@" + echo "Could not run gdb -args ${GIT_EXEC_PATH}/@@PROG@@ $*" >&2 + exit 1 +fi + exec "${GIT_EXEC_PATH}/@@PROG@@" "$@" From 1ec644a3e1de7d6c7e1f98e63e2ee2ecb4e1e7ab Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 31 Mar 2015 17:14:55 +0100 Subject: [PATCH 5/7] Squelch warning about an integer overflow We cannot rely on long integers to have more than 32 bits... Signed-off-by: Johannes Schindelin --- git-compat-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index c6d391f864..68a86a4a36 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -568,7 +568,7 @@ extern int git_lstat(const char *, struct stat *); #endif #define DEFAULT_PACKED_GIT_LIMIT \ - ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256)) + ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256)) #ifdef NO_PREAD #define pread git_pread From 4019525c50fbf03cd30d298c872c030f54fe75f8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 31 Mar 2015 18:07:05 +0100 Subject: [PATCH 6/7] Silence GCC's "cast of pointer to integer of a different size" warning When calculating hashes from pointers, it actually makes sense to cut off the most significant bits. In that case, said warning does not make a whole lot of sense. So let's just work around it. Signed-off-by: Johannes Schindelin --- compat/regex/regcomp.c | 6 ++++-- pack-revindex.c | 2 +- sha1_file.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index 06f3088708..fba5986399 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -18,6 +18,8 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, size_t length, reg_syntax_t syntax); static void re_compile_fastmap_iter (regex_t *bufp, @@ -2577,7 +2579,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, old_tree = NULL; if (elem->token.type == SUBEXP) - postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); + postorder (elem, mark_opt_subexp, (void *) (intptr_t) elem->token.opr.idx); tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); if (BE (tree == NULL, 0)) @@ -3806,7 +3808,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node) { - int idx = (int) (long) extra; + int idx = (int) (intptr_t) extra; if (node->token.type == SUBEXP && node->token.opr.idx == idx) node->token.opt_subexp = 1; diff --git a/pack-revindex.c b/pack-revindex.c index 5c8376e978..e542ea7703 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -21,7 +21,7 @@ static int pack_revindex_hashsz; static int pack_revindex_ix(struct packed_git *p) { - unsigned long ui = (unsigned long)p; + unsigned long ui = (unsigned long)(intptr_t)p; int i; ui = ui ^ (ui >> 16); /* defeat structure alignment */ diff --git a/sha1_file.c b/sha1_file.c index 1cee438422..5dae2cb9a0 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2089,7 +2089,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset) { unsigned long hash; - hash = (unsigned long)p + (unsigned long)base_offset; + hash = (unsigned long)(intptr_t)p + (unsigned long)base_offset; hash += (hash >> 8) + (hash >> 16); return hash % MAX_DELTA_CACHE; } From 084500e523342b57033f96aac3b9d63b3d74eaed Mon Sep 17 00:00:00 2001 From: Waldek Maleska Date: Tue, 31 Mar 2015 19:47:09 +0100 Subject: [PATCH 7/7] Correct fscanf formatting string for I64u values Signed-off-by: Waldek Maleska Signed-off-by: Johannes Schindelin --- builtin/gc.c | 2 +- git-compat-util.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/builtin/gc.c b/builtin/gc.c index 4957c39032..49f33eb1e0 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -227,7 +227,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid) * running. */ time(NULL) - st.st_mtime <= 12 * 3600 && - fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 && + fscanf(fp, "%"SCNuMAX" %127c", &pid, locking_host) == 2 && /* be gentle to concurrent "gc" on remote hosts */ (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM); if (fp != NULL) diff --git a/git-compat-util.h b/git-compat-util.h index 68a86a4a36..1715630c02 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -296,6 +296,10 @@ extern char *gitbasename(char *); #define PRIuMAX "llu" #endif +#ifndef SCNuMAX +#define SCNuMAX PRIuMAX +#endif + #ifndef PRIu32 #define PRIu32 "u" #endif