From patchwork Wed Feb 1 11:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13124172 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5559DC636D3 for ; Wed, 1 Feb 2023 11:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbjBALbs (ORCPT ); Wed, 1 Feb 2023 06:31:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjBALbp (ORCPT ); Wed, 1 Feb 2023 06:31:45 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7F5CDC6 for ; Wed, 1 Feb 2023 03:31:44 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so1721145pjl.0 for ; Wed, 01 Feb 2023 03:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d/+jBufBzqSO8AXH8OHLDAdrF5XD4WcFghNgoMuS2J0=; b=KUAXAiiVo6DJFM8Rd5YAQvNDa07A9JWRC+hB2VRVUNN+6HSaCsmdMQAy4s5hkJm7h5 9o/9TpaJ/vE7xzJn0Xnm37FLlxoneeX2m0uNIapUHglnSjr/oXDQ5EvTsVnKdo5KKvjG du4U7vn04QQtes/hd3luPFD09FjvHPLHVVOKMC8QWgjgxtPizA/+Lh9pJgcg3uyoi94J mkAzrRJdRK5ZYOTrGd+RAeIDlpH6bpUcyZZF1fQc25fTXMeQI01pCFmk5gAZpeAZsIb1 9wB2qMvxlmy3ML+FOIuw1T9zqGVrnixALp3XvDV7zYuPiWGE4qwUK5WofVA7tzPGB/BO EvuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d/+jBufBzqSO8AXH8OHLDAdrF5XD4WcFghNgoMuS2J0=; b=H9U/L46zg5M3WYWdAa2ZKjlurtWSQWieSZVY1kHuZO+6AW0w467K+Qa5jPDMBddi5O Pkqc3eSgAS4XSHwfHAoy/Gw7XtR12OIR2vEWu6uIK4lcGuCoETW+MRCrncel8ummUiP0 s4PdbLkqDK2dEXkJ8VPRGYlgitz7kZBE+QQOpXw3NR9uXVET7VA8152GxhsvzDilnB9S dJzP9q8+LLmuxCsiz2PjBo1pw8X7nzUAtcSjDkNgk2/l14MezIOjsPIBSH2ihblVP1oo tx9nH/QkLa9tAHHitqiHq5N+UbH9p1aDSBOCV4fZdB10+m4CnGjFdj+pt9xLDeLXtvvD Fs/w== X-Gm-Message-State: AO0yUKXTOBee1v8nDGnhpHn9W+74G4bXsxNM5uRcUkxWchlKUd7/8mlL X7mP8ZEnnFrBy6E946cGyxz5v9gz7qw= X-Google-Smtp-Source: AK7set92FEjoTeDnRzGCR2lAFUGEC2E2b4g6lnsP447InS7LfFdjDQeHpjX+rciViwT4kWHSBec9vQ== X-Received: by 2002:a17:902:f543:b0:196:5f76:1e51 with SMTP id h3-20020a170902f54300b001965f761e51mr1978843plf.64.1675251104002; Wed, 01 Feb 2023 03:31:44 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id q5-20020a170902c74500b00195f0fb0c18sm11641579plq.31.2023.02.01.03.31.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2023 03:31:43 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Bernhard Reiter , Remi Pommarel Cc: Jiang Xin , Jiang Xin Subject: [PATCH 1/2] Makefile: not use mismatched curl_config to check version Date: Wed, 1 Feb 2023 19:31:32 +0800 Message-Id: <20230201113133.10195-1-worldhello.net@gmail.com> X-Mailer: git-send-email 2.32.0.rc3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jiang Xin We may install different versions of curl, E.g.: * A system default curl, which version is below 7.34.0, is installed in "/usr", and the "curl_config" program is located in "/usr/bin/". * A higher version of curl is installed in "/opt/git/embedded/", and the "curl_config" program is located in "/opt/git/embedded/bin/". If we add the path "/opt/git/embedded/bin" in search PATH, and install git using command "make && sudo make install", the source code may be compiled twice. This is because when we run "make" using normal user account, make will call "/opt/git/embedded/bin/curl_config" to check curl version, and will set variable USE_CURL_FOR_IMAP_SEND. But when we call "make install" using root user's account, we call the system default version of curl_config to check curl version, and will lead to a different "GIT-CFLAGS" file, and will recompile all source code again. Append "$(CURLDIR)/bin" before the "CURL_CONFIG" variable to use the specific "curl_config" program we want to check curl version, we will get the correct "CURL_CFLAGS" and "CURL_LDFLAGS" variables, and we can also have a stable "GIT-CFLAGS" file to prevent recompile when running "sudo make install". Signed-off-by: Jiang Xin --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 45bd6ac9c3..f4eaf22523 100644 --- a/Makefile +++ b/Makefile @@ -1597,6 +1597,7 @@ else # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case. CURL_CFLAGS = -I$(CURLDIR)/include CURL_LIBCURL = -L$(CURLDIR)/$(lib) $(CC_LD_DYNPATH)$(CURLDIR)/$(lib) + CURL_CONFIG := $(CURLDIR)/bin/$(CURL_CONFIG) else CURL_CFLAGS = CURL_LIBCURL = From patchwork Wed Feb 1 11:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Xin X-Patchwork-Id: 13124173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04EF4C636D4 for ; Wed, 1 Feb 2023 11:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbjBALbt (ORCPT ); Wed, 1 Feb 2023 06:31:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjBALbs (ORCPT ); Wed, 1 Feb 2023 06:31:48 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E92A714E8C for ; Wed, 1 Feb 2023 03:31:46 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id m2so13141689plg.4 for ; Wed, 01 Feb 2023 03:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eV5iY8IF77qyhKNQCv8BS8boPxDmNUjlv+M7NhVd2ic=; b=PynnrcUpsn5A5raOKmKjtBflZQpIweNe3YSP8ofNH6YzwgiHz0KkIopeCCzWkDjkG4 fVlB+Pjg1/jai/+ixyT6fx230cE5Ll6Mul0VQxxm2ULMbrEnJUuXiX7DOHZ8q2vmINLu 8cc/hgD8Gt5f7gVanpBpqGEb/Di9t/lxN2DiYYXqJ4e8LEZSk2tLj+EVRgptPUT+MzoK wi/vZ8QX51dR3xJ/dxVNa+2izsFBr3zzRNzmhd21kHw6bt1k9y0L/Uw1LOOYNzw3YMEE i1/1cx5xCYp5+NP7NYRxkYTr01LFQoLVMulTIiYhhGZHnrxbmQNOk46qS8t1AYmakZGb Ltxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eV5iY8IF77qyhKNQCv8BS8boPxDmNUjlv+M7NhVd2ic=; b=5AO9m4RoKNZ/wwXcmzPOqOUTMKSIwN39LgpWo2rXbAfy6UQCwM4N6sqabpzyNh6FXZ x9B5MTjL2E7rvyIJVF37NfpjEKEsV+zPqybbkxbA+bAqdG3z20xCdO0eTL4sRON5F0Q/ MXbYUfKp5PtVVpRoGDtCkkFt5Tpz0Ji+3m8Ok9wiDgihhDP6hyfmxOS89sSGp9hxDbuF djvEXv+qfPjj4QvW/o7Yl+hEqQv97Vn6jdLgkkF5YTgEb9RaOuBaFwF5j2kG0PYb3IsK i8TLkL6kE90lFoVtL6fh342j0LuIjNQswdwpTPu8HumuVkgeC77vIxWed570XbPbxBYy baUA== X-Gm-Message-State: AO0yUKVS5zi7cfZo6B+5VR0Z7t7niHqPU6JgNI5XIbaxaz8t4H8/0+N7 9JjZKK6Ewj6k9O9ckWqpw0GLbL9rv1U= X-Google-Smtp-Source: AK7set9jfGnnskuzPF6yEZiAQ18A9YP/qsAFvkliUBetunoeGhm3+C/o2md6Wg+BbVAHDIQf/Eo/0w== X-Received: by 2002:a17:903:2013:b0:198:b54c:8fd1 with SMTP id s19-20020a170903201300b00198b54c8fd1mr552029pla.58.1675251106226; Wed, 01 Feb 2023 03:31:46 -0800 (PST) Received: from tigtog-proxy.localdomain.localdomain (144.34.163.219.16clouds.com. [144.34.163.219]) by smtp.gmail.com with ESMTPSA id q5-20020a170902c74500b00195f0fb0c18sm11641579plq.31.2023.02.01.03.31.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2023 03:31:45 -0800 (PST) From: Jiang Xin To: Git List , Junio C Hamano , Bernhard Reiter , Remi Pommarel Cc: Jiang Xin , Jiang Xin Subject: [PATCH 2/2] imap-send: not define USE_CURL_FOR_IMAP_SEND in Makefile Date: Wed, 1 Feb 2023 19:31:33 +0800 Message-Id: <20230201113133.10195-2-worldhello.net@gmail.com> X-Mailer: git-send-email 2.32.0.rc3 In-Reply-To: <20230201113133.10195-1-worldhello.net@gmail.com> References: <20230201113133.10195-1-worldhello.net@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Jiang Xin The definition and using of macro "USE_CURL_FOR_IMAP_SEND" are at different locations. It is defined in Makefile and is used in file "imap-send.c". Even though we have fixed the mismatched "curl_config" issue in Makefile in the previous commit, moving the definition of the macro "USE_CURL_FOR_IMAP_SEND" to souce code "imap-send.c" seems more nature and may help us to use curl in imap-send by force in future by removing "USE_CURL_FOR_IMAP_SEND". The side effect of this change is that the "git-imap-send" program may be larger than necessary if we have a lower version of libcurl installed. Signed-off-by: Jiang Xin --- Makefile | 11 ++--------- contrib/buildsystems/CMakeLists.txt | 3 --- imap-send.c | 29 +++++++++++++++++------------ 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index f4eaf22523..83721216fc 100644 --- a/Makefile +++ b/Makefile @@ -1621,15 +1621,8 @@ else ifndef NO_EXPAT PROGRAM_OBJS += http-push.o 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" - USE_CURL_FOR_IMAP_SEND = YesPlease - endif - ifdef USE_CURL_FOR_IMAP_SEND - BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND - IMAP_SEND_BUILDDEPS = http.o - IMAP_SEND_LDFLAGS += $(CURL_LIBCURL) - endif + IMAP_SEND_BUILDDEPS = http.o + IMAP_SEND_LDFLAGS += $(CURL_LIBCURL) ifndef NO_EXPAT ifdef EXPATDIR BASIC_CFLAGS += -I$(EXPATDIR)/include diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt index 2f6e0197ff..d508db4d29 100644 --- a/contrib/buildsystems/CMakeLists.txt +++ b/contrib/buildsystems/CMakeLists.txt @@ -622,9 +622,6 @@ if(NOT CURL_FOUND) message(WARNING "git-http-push and git-http-fetch will not be built") else() list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http) - if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0) - add_compile_definitions(USE_CURL_FOR_IMAP_SEND) - endif() endif() if(NOT EXPAT_FOUND) diff --git a/imap-send.c b/imap-send.c index a50af56b82..c0a2c2b4e6 100644 --- a/imap-send.c +++ b/imap-send.c @@ -30,20 +30,25 @@ #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG) typedef void *SSL; #endif -#ifdef USE_CURL_FOR_IMAP_SEND +#ifdef NO_CURL +#define USE_CURL_FOR_IMAP_SEND 0 +#else #include "http.h" -#endif - -#if defined(USE_CURL_FOR_IMAP_SEND) -/* Always default to curl if it's available. */ -#define USE_CURL_DEFAULT 1 +/* + * Since version 7.30.0, libcurl's API has been able to communicate with + * IMAP servers, and curl's CURLOPT_LOGIN_OPTIONS (enabling IMAP + * authentication) parameter is available if curl's version is >= 7.34.0, + * Always use curl if there is a matching libcurl. + */ +#if LIBCURL_VERSION_NUM >= 0x072200 +#define USE_CURL_FOR_IMAP_SEND 1 #else -/* We don't have curl, so continue to use the historical implementation */ -#define USE_CURL_DEFAULT 0 +#define USE_CURL_FOR_IMAP_SEND 0 +#endif #endif static int verbosity; -static int use_curl = USE_CURL_DEFAULT; +static int use_curl = USE_CURL_FOR_IMAP_SEND; static const char * const imap_send_usage[] = { "git imap-send [-v] [-q] [--[no-]curl] < ", NULL }; @@ -1396,7 +1401,7 @@ static int append_msgs_to_imap(struct imap_server_conf *server, return 0; } -#ifdef USE_CURL_FOR_IMAP_SEND +#if USE_CURL_FOR_IMAP_SEND static CURL *setup_curl(struct imap_server_conf *srvc, struct credential *cred) { CURL *curl; @@ -1531,7 +1536,7 @@ int cmd_main(int argc, const char **argv) if (argc) usage_with_options(imap_send_usage, imap_send_options); -#ifndef USE_CURL_FOR_IMAP_SEND +#if !USE_CURL_FOR_IMAP_SEND if (use_curl) { warning("--curl not supported in this build"); use_curl = 0; @@ -1580,7 +1585,7 @@ int cmd_main(int argc, const char **argv) if (server.tunnel) return append_msgs_to_imap(&server, &all_msgs, total); -#ifdef USE_CURL_FOR_IMAP_SEND +#if USE_CURL_FOR_IMAP_SEND if (use_curl) return curl_append_msgs_to_imap(&server, &all_msgs, total); #endif