From patchwork Fri Aug 13 09:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12435165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF88DC4338F for ; Fri, 13 Aug 2021 09:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE0256024A for ; Fri, 13 Aug 2021 09:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239291AbhHMJPr (ORCPT ); Fri, 13 Aug 2021 05:15:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbhHMJPn (ORCPT ); Fri, 13 Aug 2021 05:15:43 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07264C061756 for ; Fri, 13 Aug 2021 02:15:17 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id om1-20020a17090b3a8100b0017941c44ce4so1439552pjb.3 for ; Fri, 13 Aug 2021 02:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e7zw7nNM5IRHgIdOMC/vOQu7sPAzLKedqwrdkrfxiG8=; b=o5ZvMH7n0R2EiuoC5FJkXed9OJUmlzcYO0vR3uOZTLv4PaUJ4THdv9JXI7QPiOSRzV daJp/jiVPbpM7XFKAJizMm2aVS3g7Bz6BMR9QZqlIB0fa6mR8En4/WtGrgm01NW1XmbB Wfme6eKuRq9kfdTO75N7sc3Yk6mavJJqqbhT9IHdKTSpnQY8eZ5i/D31jtslfgP/g1Uo qzNCImCblLcMrjkEPAvOFBQtEZnwmd4ldM1y1pfEgy8HqawNXSEnTc6k3gWTheEU9lxL NDT9Jq/8tLxhXyXXliDJZDYp5fAYZF5JkLs/fGFi3+l/6Q0176E9NzhUi/co17aRmd66 ohFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e7zw7nNM5IRHgIdOMC/vOQu7sPAzLKedqwrdkrfxiG8=; b=ObtaqGjR9aBFMEsO1TBPCcNZPbc3VpN4MKKijo/+WNc/f6tsMW5J2tB7+46aNix+sX sPXobws7uDevV7ynmvC6FBJqKRKofgVX8euVM+Dnk7MR+RAYnu97XRJkGi0BotcpFJ5q hKtiqPf4T7rVJHvfcPTQvWtv8b5vTmzNcHvLoYeo1WAa0wZIYW4IavXc9e4Sisr4c1xc /sQp5cKRvRvi8Dwv53nN4VbZbDhqp8hYgbNZPHcstjqDr+3+/znOrX63g18LWseRDWkc JbbBvbBFTaTdR9INP0zGaSSAYm0Nn84S09TIxrArsKNKDnen2reBKOCldO37d7cIg2dd 2aYg== X-Gm-Message-State: AOAM532uhYPhX7gwfzWBo2OzWilF0wI02D08IUwOiMeOL9smeAENpFJM oKEV9Zv4JplFgoaXP43qO58= X-Google-Smtp-Source: ABdhPJzdH1MBwJzpttQVBMb4esZr/4Vhf4S4Pd/z9vVV3kNPxCEiwrddhCkSjQksSRAWs7rpJosxvw== X-Received: by 2002:a63:a4d:: with SMTP id z13mr1460508pgk.445.1628846116574; Fri, 13 Aug 2021 02:15:16 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.158]) by smtp.gmail.com with ESMTPSA id p17sm1286968pjg.54.2021.08.13.02.15.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Aug 2021 02:15:16 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: git@vger.kernel.org, avarab@gmail.com, jonathantanmy@google.com Subject: [PATCH v1 1/3] packfile-uri: http and https as default value of `--uri-protocol` Date: Fri, 13 Aug 2021 17:14:54 +0800 Message-Id: <0754ea6472f2665a5fe77de080434d3734c67259.1628845748.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.32.0.1.g0de8fe24d1.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org HTTP(S) is usually one of the most common protocols, using "http" and "https" as the default parameter values of `--uri-protocol`, which can simplify the use of packfile-uri feature on client side when run a git-clone or git-fetch. Signed-off-by: Teng Long --- builtin/pack-objects.c | 18 +++++++++++++++--- fetch-pack.c | 13 ++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index de00adbb9e..5f6db92a4c 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3892,6 +3892,18 @@ static int option_parse_unpack_unreachable(const struct option *opt, return 0; } +static int option_parse_uri_protocol(const struct option *opt, + const char *arg, int unset) +{ + if (!arg) { + string_list_append(&uri_protocols, "http"); + string_list_append(&uri_protocols, "https"); + } else { + string_list_append(&uri_protocols, arg); + } + return 0; +} + int cmd_pack_objects(int argc, const char **argv, const char *prefix) { int use_internal_rev_list = 0; @@ -3995,9 +4007,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) N_("do not pack objects in promisor packfiles")), OPT_BOOL(0, "delta-islands", &use_delta_islands, N_("respect islands during delta compression")), - OPT_STRING_LIST(0, "uri-protocol", &uri_protocols, - N_("protocol"), - N_("exclude any configured uploadpack.blobpackfileuri with this protocol")), + OPT_CALLBACK_F(0, "uri-protocol", NULL, N_("protocol"), + N_("exclude any configured uploadpack.blobpackfileuri with this protocol"), + PARSE_OPT_OPTARG, option_parse_uri_protocol), OPT_END(), }; diff --git a/fetch-pack.c b/fetch-pack.c index c135635e34..511a892d4c 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1755,11 +1755,14 @@ static void fetch_pack_config(void) git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects); git_config_get_bool("transfer.advertisesid", &advertise_sid); if (!uri_protocols.nr) { - char *str; - - if (!git_config_get_string("fetch.uriprotocols", &str) && str) { - string_list_split(&uri_protocols, str, ',', -1); - free(str); + const char *value; + + if (!git_config_get_value("fetch.uriprotocols", &value)) { + if (!value || !strcmp(value, "")) { + string_list_append(&uri_protocols, "http"); + string_list_append(&uri_protocols, "https"); + } else + string_list_split(&uri_protocols, value, ',', -1); } } From patchwork Fri Aug 13 09:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12435167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 712FFC4320A for ; Fri, 13 Aug 2021 09:15:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 604CD6024A for ; Fri, 13 Aug 2021 09:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239124AbhHMJPs (ORCPT ); Fri, 13 Aug 2021 05:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239298AbhHMJPr (ORCPT ); Fri, 13 Aug 2021 05:15:47 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E39C0617AE for ; Fri, 13 Aug 2021 02:15:21 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d1so11110462pll.1 for ; Fri, 13 Aug 2021 02:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cQaM2pCdZ6/xsqjyfNVCIfzMUlR2erZA+YEMcVd+Bbk=; b=rgEw0sJd9iXzfR3d21DX4FAoLHRbRtiD4oF2dtH6fZUjWchDG6Pp51oeHBGmWqhYL2 BuhyM8qvvyol5i9jIlB8vXhzQm9/3qHkYlQz5oHgt0GKfmHJ3TjFy7rNhhSIIVHLOADW aARdVbudGEK5/DfOBXBOdiMVKf7U0gYIIQWx2Ucd0Ol6+sPgoJFTEfifF+7+Uwo4WhzS Atr7CvbN2H8u8zW/vcDPqdiKzutF5vrHOnMKjdUXPQT0xf6cwktN0x82YNMS8xTJG5kZ wh8aslS4Ym4Sta48VXHvNiccnRwyLltVDZnJn55c4idhR/i+Ovjou6SQdks7n1q7kauT 3/Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cQaM2pCdZ6/xsqjyfNVCIfzMUlR2erZA+YEMcVd+Bbk=; b=nN3imbZU/hFX3x8FnyTl2MbspACnr3CAdLq8I7Yox6f229y/MiN3AU/ClIpePGfe+b 8KylrDeXjhOP90qqP491vBD7b90cQO8on5RPpKANUSxMpDu2cWAdxcR5LZNIOqk6ekvf j3vR9BXGGhAxEr+bruHdPiEoxibmHAHzpq3LXaij5YKXSgNDTpxLJsxxLU3AmDSbQU7i rkkXjvx+e0nNTv+hIXv2jkwkFArAZXk91Z7PNOwfFgZcpg95PdA787HcXxpAw4rtimO0 3xwWTw/rLIpm/YQ08zsJAICow3aXJ4JwZNL0tvU8CZQq/J5CWs8YF7cqE652pYwiRTqJ Q54g== X-Gm-Message-State: AOAM533hfDE03M3pO03FhrLEgnbqyvOu/AVpSXnatvP779KvILmAgDR6 L6cFqMqDsG+ovOC4NnvvdAY= X-Google-Smtp-Source: ABdhPJwqS8neR9qvIXz0kZl84GXmj/OZ2D+xSj/CRDECNUfnbmulx0oEKscNTW/gxn7I84TqeW1L3Q== X-Received: by 2002:a63:cd4c:: with SMTP id a12mr1459973pgj.449.1628846120848; Fri, 13 Aug 2021 02:15:20 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.158]) by smtp.gmail.com with ESMTPSA id p17sm1286968pjg.54.2021.08.13.02.15.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Aug 2021 02:15:20 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: git@vger.kernel.org, avarab@gmail.com, jonathantanmy@google.com Subject: [PATCH v1 2/3] git-pack-objects.txt: introduce `--uri-protocol` option Date: Fri, 13 Aug 2021 17:14:55 +0800 Message-Id: <307a1837196a1508963a70bf4c0c4ac5727e4d19.1628845748.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.32.0.1.g0de8fe24d1.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Teng Long --- Documentation/git-pack-objects.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index 25d9fbe37a..16057b8c7d 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -313,6 +313,14 @@ raise an error. --unpack-unreachable:: Keep unreachable objects in loose form. This implies `--revs`. +--uri-protocol:: + Exclude objects which hit the KEY (the object hash) of + `uploadpack.excludeobject` or `uploadpack.blobpackfileuri` + config (See linkgit:packfile-uri[1]) in repository and the + VALUE (the packfile uri) matches the given option parameter. + If this option is set, but without a value, it defaults to + the value will be "http" and "https". + --delta-islands:: Restrict delta matches based on "islands". See DELTA ISLANDS below. @@ -426,6 +434,7 @@ SEE ALSO linkgit:git-rev-list[1] linkgit:git-repack[1] linkgit:git-prune-packed[1] +linkgit:packfile-uri[1] GIT --- From patchwork Fri Aug 13 09:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12435185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15281C4338F for ; Fri, 13 Aug 2021 09:15:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED27C6109E for ; Fri, 13 Aug 2021 09:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239354AbhHMJPz (ORCPT ); Fri, 13 Aug 2021 05:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239179AbhHMJPy (ORCPT ); Fri, 13 Aug 2021 05:15:54 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F150C061756 for ; Fri, 13 Aug 2021 02:15:28 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id a8so14350348pjk.4 for ; Fri, 13 Aug 2021 02:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lEn4oeBK8CxlcAsOA0DPqcVBzgH8Xm3ZiDrENDy2Yj8=; b=jOmGI9w70ydIMl+XmmKMrePPgcczufzF/19xluFHgaBBgRzD7Zga5apjq6o6TmvRHX fsipNN4eJDthA0OmLXi1D/OSOljKylCuH2/moUJUWwnN36MnvUezKu+eF1LVgmlfXuzE ++6CYVhlqAXoILYPiV8vAw/nDl+sCpzg+FfxQFMDXjejgfI2KUwOEU/+GefL300IFFPM grXxMXqIZkNiOmsYgGQpPoDDVZZ9O2IICLGB92lb00Z+QNVJiSetXKRCApU6nmCha1oo crpBh9IIO+MtkTH2EmBKxEU5ke0j8rViIhKXRQp4fzA0GAdm7yti02fty4+ITO69VulS QPfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lEn4oeBK8CxlcAsOA0DPqcVBzgH8Xm3ZiDrENDy2Yj8=; b=PoqZggLPNBOUznrymqvvVBDgbxJPXq9cm2gqhSeIc28gVtxyaD+dvj2QGaSHvhoSce Iqu5ThKh0c1GSuZtFibe8Cd7q3+E8vvltjeBR3fO4b1JNUqCYX1ER5sd3BiKClZz2oNw pRnV3zv+yHNkRLFxLmI+UZREE1MCf1wyqfrAYdw1blgI8L9P/xsX9+oOwaLIf24t7J9n fH8QlEOLx8JbhW4lfwPEpZTt9tGHh/GkEbibRCzTiHhV0zJD//RBp3MzAVwHSbQeqOwZ XSgHa3PfLzknoMWtKrZRqv7DjloBEJ9ElF2MBDiedxXi3ITgIsdE0MiG1xRsLanIX+wG NDPg== X-Gm-Message-State: AOAM530ggsMk4GXPR+4CVvrK7e5YA5f9D7U7HIc68fE8LQPkG0ZaUHbn 3sGsHbREi14XFmuve42032w= X-Google-Smtp-Source: ABdhPJzK65XOnUUaAcRz2rfS2xWKOCcZmoWoFaS4NI/60QxZ3cta1yJs+P9LCvFnADjA9KtoJ/hJ2A== X-Received: by 2002:a17:90a:fb81:: with SMTP id cp1mr1727611pjb.52.1628846128149; Fri, 13 Aug 2021 02:15:28 -0700 (PDT) Received: from localhost.localdomain ([47.246.98.158]) by smtp.gmail.com with ESMTPSA id p17sm1286968pjg.54.2021.08.13.02.15.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Aug 2021 02:15:27 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: git@vger.kernel.org, avarab@gmail.com, jonathantanmy@google.com Subject: [PATCH v1 3/3] t5702: `fetch.uriprotocols` is configured without value Date: Fri, 13 Aug 2021 17:14:56 +0800 Message-Id: <3ee54255440fcc5cf549ab5e98fa51bbcd5df2e1.1628845748.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.32.0.1.g0de8fe24d1.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Teng Long --- t/t5702-protocol-v2.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 66af411057..cf3bc89775 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -945,6 +945,29 @@ test_expect_success 'packfile URIs with fetch instead of clone' ' fetch "$HTTPD_URL/smart/http_parent" ' +test_expect_success 'packfile URIs with fetch by default `fetch.uriprotocols` config' ' + P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && + rm -rf "$P" http_child log && + + git init "$P" && + git -C "$P" config "uploadpack.allowsidebandall" "true" && + + echo my-blob >"$P/my-blob" && + git -C "$P" add my-blob && + git -C "$P" commit -m x && + + configure_exclusion "$P" my-blob >h && + + git init http_child && + + GIT_TEST_SIDEBAND_ALL=1 GIT_TRACE_PACKET=`pwd`/log \ + git -C http_child \ + -c protocol.version=2 \ + -c fetch.uriprotocols \ + fetch "$HTTPD_URL/smart/http_parent" && + grep "git< packfile-uris http,https" log +' + test_expect_success 'fetching with valid packfile URI but invalid hash fails' ' P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" && rm -rf "$P" http_child log &&