From patchwork Thu Dec 13 15:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B68DA91E for ; Thu, 13 Dec 2018 15:58:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A38F72A405 for ; Thu, 13 Dec 2018 15:58:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B1522ADE7; Thu, 13 Dec 2018 15:58:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75AEA2A898 for ; Thu, 13 Dec 2018 15:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729093AbeLMP6b (ORCPT ); Thu, 13 Dec 2018 10:58:31 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35791 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728931AbeLMP6a (ORCPT ); Thu, 13 Dec 2018 10:58:30 -0500 Received: by mail-wr1-f66.google.com with SMTP id 96so2554485wrb.2 for ; Thu, 13 Dec 2018 07:58:29 -0800 (PST) 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=1edgIllYJ2wnLizBgABFmxOPPXGmsOwnqOIRskQPNjQ=; b=NTVBHH0W2r9Z3CMsLqZWet79M6IA1wEqffs/Vv+UhiDt+vms09IxE8JxtlV/A+w6Pq tU5V/ZW+UUI3w2i0Jib6fkTlitwGMrPvfe5XYWQ1LgbqzdcpZKAWAohqCukQj+f4miu0 WQfIwOpwzpTPSyggrOgmBdUHrdCCG4NffgZy1E8m1ZqEakW/lrIG0iE67soIh7qG7u25 6Ekg1OZ0EnCGhdJpVnxq/2mHdoZitb7nZ9oBusf/ZMSt6XC+FK+jGo+/gaFr+UMrOP0T ySu4G7rhH+DE5jNZbC4gIuZl4qpxQUVwQtUi03NNwqG3W6M7BbJT3w//0FUUczf1DutW upXQ== 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=1edgIllYJ2wnLizBgABFmxOPPXGmsOwnqOIRskQPNjQ=; b=Dc44fwn6W0KM7AIAwxbw7+4pc8XKJPsEptspRQDRc6IrJnax89IF96yk7yj2MaGLjx kRKNEL3RNWsO6dIYAulbZWFSUgqoYyVbk63P4YygGzDxRNxVTkn8j6RwFr/dy3rV/yh+ kWtp+KiMZuLqnoOqqLPUaiaVyKBw/JMfCAGLKWi+oboFDDXFMnlFnH61O62sjEIMlzLG cBixxZoBT8NW6McpQOZegJv/kzonajckKOyqHjiHnlOpYznDWRenW4xkvyZ/1emlo+ji 7wb3iFAOwupd9DFhEWby6wWCQw54XZ/ttZp1ksAcfzNB4zay4rlcbZiXdgSs2oy4f3zi +MKQ== X-Gm-Message-State: AA+aEWanihJmFC7UnB/Y8RfIWmaV5uCweOxVBOD/oU/bPk8QfL+exdWI eQ+B0UlHecR41EyBssOcxptGcHl5 X-Google-Smtp-Source: AFSGD/Ufc4ulI9YuGOQocxR4vGz88etaTt6jNvuvy9PO9J7Qpl/jB4mso/GxKzDbpZkwWK/iUUsrEQ== X-Received: by 2002:adf:a393:: with SMTP id l19mr22081728wrb.110.1544716708594; Thu, 13 Dec 2018 07:58:28 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:27 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 1/8] serve: pass "config context" through to individual commands Date: Thu, 13 Dec 2018 16:58:10 +0100 Message-Id: <20181213155817.27666-2-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff King In protocol v2, instead of just running "upload-pack", we have a generic "serve" loop which runs command requests from the client. What used to be "upload-pack" is now generally split into two operations: "ls-refs" and "fetch". The latter knows it must respect uploadpack.* config, but the former is not actually specific to a fetch operation (we do not yet do v2 receive-pack, but eventually we may, and ls-refs would support both operations). However, ls-refs does need to know which operation we're performing, in order to read the correct config (e.g., uploadpack.hiderefs versus receive.hiderefs; we don't read _either_ right now, but this is the first step to fixing that). In the generic "git-serve" program, we don't have that information. But in the protocol as it is actually used by clients, the client still asks to run "git-upload-pack", and then issues an "ls-refs" from there. So we _do_ know at that point that "uploadpack" is the right config context. This patch teaches the protocol v2 "serve" code to pass that context through to the individual commands (a future patch will teach ls-refs to actually use it). Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/upload-pack.c | 1 + ls-refs.c | 4 +++- ls-refs.h | 3 ++- serve.c | 9 +++++---- serve.h | 7 +++++++ upload-pack.c | 4 ++-- upload-pack.h | 4 ++-- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c index 42dc4da5a1..67192cfa9e 100644 --- a/builtin/upload-pack.c +++ b/builtin/upload-pack.c @@ -52,6 +52,7 @@ int cmd_upload_pack(int argc, const char **argv, const char *prefix) case protocol_v2: serve_opts.advertise_capabilities = opts.advertise_refs; serve_opts.stateless_rpc = opts.stateless_rpc; + serve_opts.config_context = "uploadpack"; serve(&serve_opts); break; case protocol_v1: diff --git a/ls-refs.c b/ls-refs.c index a06f12eca8..e8e31475f0 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -69,7 +69,9 @@ static int send_ref(const char *refname, const struct object_id *oid, return 0; } -int ls_refs(struct repository *r, struct argv_array *keys, +int ls_refs(struct repository *r, + const char *config_section, + struct argv_array *keys, struct packet_reader *request) { struct ls_refs_data data; diff --git a/ls-refs.h b/ls-refs.h index b62877e8da..da26fc9824 100644 --- a/ls-refs.h +++ b/ls-refs.h @@ -4,7 +4,8 @@ struct repository; struct argv_array; struct packet_reader; -extern int ls_refs(struct repository *r, struct argv_array *keys, +extern int ls_refs(struct repository *r, const char *config_context, + struct argv_array *keys, struct packet_reader *request); #endif /* LS_REFS_H */ diff --git a/serve.c b/serve.c index bda085f09c..70f89cf0d9 100644 --- a/serve.c +++ b/serve.c @@ -48,6 +48,7 @@ struct protocol_capability { * This field should be NULL for capabilities which are not commands. */ int (*command)(struct repository *r, + const char *config_context, struct argv_array *keys, struct packet_reader *request); }; @@ -158,7 +159,7 @@ enum request_state { PROCESS_REQUEST_DONE, }; -static int process_request(void) +static int process_request(struct serve_options *opts) { enum request_state state = PROCESS_REQUEST_KEYS; struct packet_reader reader; @@ -222,7 +223,7 @@ static int process_request(void) if (!command) die("no command requested"); - command->command(the_repository, &keys, &reader); + command->command(the_repository, opts->config_context, &keys, &reader); argv_array_clear(&keys); return 0; @@ -249,10 +250,10 @@ void serve(struct serve_options *options) * a single request/response exchange */ if (options->stateless_rpc) { - process_request(); + process_request(options); } else { for (;;) - if (process_request()) + if (process_request(options)) break; } } diff --git a/serve.h b/serve.h index fe65ba9f46..d527224cbb 100644 --- a/serve.h +++ b/serve.h @@ -8,6 +8,13 @@ extern int has_capability(const struct argv_array *keys, const char *capability, struct serve_options { unsigned advertise_capabilities; unsigned stateless_rpc; + + /* + * Some operations may need to know the context when looking up config; + * e.g., set this to "uploadpack" to respect "uploadpack.hiderefs" (as + * opposed to "receive.hiderefs"). + */ + const char *config_context; }; #define SERVE_OPTIONS_INIT { 0 } extern void serve(struct serve_options *options); diff --git a/upload-pack.c b/upload-pack.c index 5e81f1ff24..914bbb40bc 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1413,8 +1413,8 @@ enum fetch_state { FETCH_DONE, }; -int upload_pack_v2(struct repository *r, struct argv_array *keys, - struct packet_reader *request) +int upload_pack_v2(struct repository *r, const char *config_context, + struct argv_array *keys, struct packet_reader *request) { enum fetch_state state = FETCH_PROCESS_ARGS; struct upload_pack_data data; diff --git a/upload-pack.h b/upload-pack.h index cab2178796..2a9f51197c 100644 --- a/upload-pack.h +++ b/upload-pack.h @@ -13,8 +13,8 @@ void upload_pack(struct upload_pack_options *options); struct repository; struct argv_array; struct packet_reader; -extern int upload_pack_v2(struct repository *r, struct argv_array *keys, - struct packet_reader *request); +extern int upload_pack_v2(struct repository *r, const char *config_context, + struct argv_array *keys, struct packet_reader *request); struct strbuf; extern int upload_pack_advertise(struct repository *r, From patchwork Thu Dec 13 15:58:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C8D091E for ; Thu, 13 Dec 2018 15:58:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BBCD2A405 for ; Thu, 13 Dec 2018 15:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FFB52A975; Thu, 13 Dec 2018 15:58:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCB9B2A405 for ; Thu, 13 Dec 2018 15:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729094AbeLMP6d (ORCPT ); Thu, 13 Dec 2018 10:58:33 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38686 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729092AbeLMP6c (ORCPT ); Thu, 13 Dec 2018 10:58:32 -0500 Received: by mail-wm1-f68.google.com with SMTP id m22so2924435wml.3 for ; Thu, 13 Dec 2018 07:58:31 -0800 (PST) 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=LaKxaf2tGfDJdn4Nhfutom5XIpCxc2Kl9ALPF0K9hAU=; b=DFLa1St/FcJ7ZxNB53yhFkYPXo1TKQqGrUgTVzOKcCSOQJfMUXRLVbYToDrb1v0wT2 E9YkHV037M2nvRPGlaiHfsZuaa4RS1ExzXlDRn7nV+1Yw33s7YUiNn2J411PCYSIpuAa ifLMB5xSaiDLlhwPPaI/bO40qCsAXrDNFPWAtsvT3gy+PwduFbfDWLrPF7ktD+aV2V70 3dX78xxGgW++AofEUXIaKlFIL6F8MhBryyMtT5q0wXbljCONheIlfEKHk00EFYjnD4P0 X/g0wwcXpCgPCPTknBcUkZsQoa7HStlq1bx5/3yvh9knFhbYkMsq1HXMpQlRjxbnCSeY zrMA== 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=LaKxaf2tGfDJdn4Nhfutom5XIpCxc2Kl9ALPF0K9hAU=; b=HgMzrXHN38Y025Fof6TVDuFV6UFHl3Ci38q9v5gBJc1cynv72qcUlz1Km888HrfL9A CFlzIQSoxSb0giXO1dHbzSmPzlXW1LGzP/cb9a7+NfMvnVDoRqOexquuJRtkd11bw5Rr bK2gbDpGInUlHgq0KRS+t9V4oSfMjX+iXPdpQxDRpzzVBOwPBZ4V+tQX5hlSb7UdaqxY 2KURiuwVOpy0ST8ogxYGI+cUyq0AY46tB7VzLF3KoJx0uQFtU/3g4W7WaI9h8JBbUBE/ +1hgKwYvyXK8CVVw/dG7CSTHcVn4A/b6D3YmWKnyc45I9vXpT4wdc+p6dAAmuG9Xo7Xm mquw== X-Gm-Message-State: AA+aEWYx3JyvGo9ZF47DWEB9c58n9ggbJNroavt2OEQgn3r6pidNWRBD 4UZ+JETyo1Mze0R/MlvbF7P4kfYw X-Google-Smtp-Source: AFSGD/Vgd1XmiRvzaDbhP/1pAbXvhnF6zq8NLcUtihSa4T5/am0m1fv+H9lAPxnURug6duBeouY6TQ== X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr10613277wmc.50.1544716710420; Thu, 13 Dec 2018 07:58:30 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:29 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 2/8] parse_hide_refs_config: handle NULL section Date: Thu, 13 Dec 2018 16:58:11 +0100 Message-Id: <20181213155817.27666-3-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff King This helper function looks for config in two places: transfer.hiderefs, or $section.hiderefs, where $section is passed in by the caller (and is "uploadpack" or "receive", depending on the context). In preparation for callers which do not even have that context (namely the "git-serve" command), let's handle a NULL by looking only at transfer.hiderefs (as opposed to segfaulting). Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- refs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index f9936355cd..099e91d9cc 100644 --- a/refs.c +++ b/refs.c @@ -1267,7 +1267,8 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti { const char *key; if (!strcmp("transfer.hiderefs", var) || - (!parse_config_key(var, section, NULL, NULL, &key) && + (section && + !parse_config_key(var, section, NULL, NULL, &key) && !strcmp(key, "hiderefs"))) { char *ref; int len; From patchwork Thu Dec 13 15:58:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2B7791E for ; Thu, 13 Dec 2018 15:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A25F62A405 for ; Thu, 13 Dec 2018 15:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9683A2A975; Thu, 13 Dec 2018 15:58:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DB802A405 for ; Thu, 13 Dec 2018 15:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729099AbeLMP6e (ORCPT ); Thu, 13 Dec 2018 10:58:34 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33985 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727707AbeLMP6d (ORCPT ); Thu, 13 Dec 2018 10:58:33 -0500 Received: by mail-wr1-f65.google.com with SMTP id j2so2563552wrw.1 for ; Thu, 13 Dec 2018 07:58:33 -0800 (PST) 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=jy4T3ZHPFqxt+jxySEedfbsUnzrKYoqatp8zUKLH4dY=; b=OzsaqBp8w1r4jSf1dDGZfbdThc3ELTSTuZ2y3vJO2HcMEoRKh5TQ5ePvVwmTHkqATB tYc1AIJa8YBMOr6cygDU+ixrccTXrkmHFvXPDrGI+UWIK0UgIBqNg36poHPz7grzBBES qTniW5k8+za973HpRfk/5p2Mzd4yfTivOq1f9TlAdfLSpKMCSpQZMDeXtKu4/HrSY7FQ c5YHNamstLt2B1E1wSZzFt5mf8+ucvmkeh1mXP4YkoQYCye/viIIS3/GSn6y3FGnSyqN CZy427tM9724rpuHa28A1UYfeFX1MhNbB2DpoMRn7PhUMPtA9hTV4EnEWk93CDHfo2sJ 7zsg== 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=jy4T3ZHPFqxt+jxySEedfbsUnzrKYoqatp8zUKLH4dY=; b=Rrqm6s3wIEPDXL/v8ddPSoKSLeRRym0uAxQ4iK/2htXCuQe8sFJxu0BnDqMorajbgE lXmT+DwfKJtwOhW9pmtRTDayAelfdohRXQnyKVDblZlOxwxbE2FsnUdMrU1FdwCWIVBZ Z8+szuwXdfdjyaiMpGXA1rQ+P38GrM26B94DEjVp59VbH8DA5MQodnl5/RmevpBj5Bzk XfSDgYPKYU9eDeSt338K4wyaHaWh80j/7LlKld4JgXRRTBhvXHmV9gq4AssSQBZLCW3i Q4sOyN47uiGAZrr3DZ8uycKVop1M7PjehwPVPx6pLyjB+xH71EJKXoFgVJPM1wlPOQyN Yy9A== X-Gm-Message-State: AA+aEWZkPRlk3RTDo+hOD07cTZInoDIlh/erNaKH7li9Y825K7UpzeQ+ yj7gTxTFoLWijY7HIr54wTcpzlrm X-Google-Smtp-Source: AFSGD/Xcqt9yhxYBaZH8x6ZngY4d3Zk5MG+qO6K9fsYQ6hNF7Xt+3shNCgGy3pknKLQcW+gkyC9xbQ== X-Received: by 2002:a5d:4286:: with SMTP id k6mr21579048wrq.225.1544716711931; Thu, 13 Dec 2018 07:58:31 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:31 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 3/8] upload-pack: support hidden refs with protocol v2 Date: Thu, 13 Dec 2018 16:58:12 +0100 Message-Id: <20181213155817.27666-4-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff King In the v2 protocol, upload-pack's advertisement has been moved to the "ls-refs" command. That command does not respect hidden-ref config (like transfer.hiderefs) at all, and advertises everything. While there are some features that are not supported in v2 (e.g., v2 always allows fetching any sha1 without respect to advertisements), the lack of this feature is not documented and is likely just a bug. Let's make it work, as otherwise upgrading a server to a v2-capable git will start exposing these refs that the repository admin has asked to remain hidden. Note that we depend on the config_context from the caller here to realize that we should respect uploadpack.hiderefs. When run from the "git-serve" tool, we won't have that context and will only respect transfer.hiderefs. This should be OK, as git-serve is not actually used for normal protocol operations. Note also that we don't need to worry about the "An attempt to update or delete a hidden ref by git push is rejected" feature of receive.hideRefs, see git-config(1). This is because there's no v2 push protocol yet. Signed-off-by: Jeff King Signed-off-by: Ævar Arnfjörð Bjarmason --- ls-refs.c | 12 ++++++++++++ t/t5512-ls-remote.sh | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/ls-refs.c b/ls-refs.c index e8e31475f0..8a8143338b 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -5,6 +5,7 @@ #include "argv-array.h" #include "ls-refs.h" #include "pkt-line.h" +#include "config.h" /* * Check if one of the prefixes is a prefix of the ref. @@ -40,6 +41,9 @@ static int send_ref(const char *refname, const struct object_id *oid, const char *refname_nons = strip_namespace(refname); struct strbuf refline = STRBUF_INIT; + if (ref_is_hidden(refname_nons, refname)) + return 0; + if (!ref_match(&data->prefixes, refname)) return 0; @@ -69,6 +73,12 @@ static int send_ref(const char *refname, const struct object_id *oid, return 0; } +static int ls_refs_config(const char *var, const char *value, + void *config_context) +{ + return parse_hide_refs_config(var, value, config_context); +} + int ls_refs(struct repository *r, const char *config_section, struct argv_array *keys, @@ -78,6 +88,8 @@ int ls_refs(struct repository *r, memset(&data, 0, sizeof(data)); + git_config(ls_refs_config, (void *)config_section); + while (packet_reader_read(request) != PACKET_READ_FLUSH) { const char *arg = request->line; const char *out; diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index 32e722db2e..ca69636fd5 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -204,6 +204,12 @@ test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs' grep refs/tags/magic actual ' +test_expect_success 'protocol v2 supports hiderefs' ' + test_config uploadpack.hiderefs refs/tags && + git -c protocol.version=2 ls-remote . >actual && + ! grep refs/tags actual +' + test_expect_success 'ls-remote --symref' ' git fetch origin && cat >expect <<-EOF && From patchwork Thu Dec 13 15:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9586A16B1 for ; Thu, 13 Dec 2018 15:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B26B28683 for ; Thu, 13 Dec 2018 15:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B9072864A; Thu, 13 Dec 2018 15:58:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B66D27F98 for ; Thu, 13 Dec 2018 15:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729115AbeLMP6g (ORCPT ); Thu, 13 Dec 2018 10:58:36 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35902 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbeLMP6g (ORCPT ); Thu, 13 Dec 2018 10:58:36 -0500 Received: by mail-wm1-f67.google.com with SMTP id a18so2937066wmj.1 for ; Thu, 13 Dec 2018 07:58:34 -0800 (PST) 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=1GbXPTXct/pMPQWS+fbnb/n4LqVVWvB76ciftr0TjSQ=; b=P9lctXLas4cygr7zxmkHBR22/Lr8r3s7eqyZeZnayiAXGnf5SULnrqrbDqEAM4YIfw vOfAoP9sTH9+irug+F3NGzvik0V36jdzfrkK8E+u4V2D6/iJPU7CqGAnl+HqHqgKk9pA /WO4TvxtCgEhwIWAkx35ePbPFN/FwCQ4u0qxSFwIg+XC/xErmWC8mH2uubthrlbVbBiZ 7eWZedatxC9Y3XxwAcNE7fNCSItvnSFUgHEpGCBezNml5GyRxdxGNrTHLBUkcZzZK1pq 0N47ZC6arE+oWQDrCQcZ42hsXMyKYRXFmBbsBY1MxhyY9YMekD3y2rVkgIsIS2WXkOS/ oLFg== 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=1GbXPTXct/pMPQWS+fbnb/n4LqVVWvB76ciftr0TjSQ=; b=qGw/kgkCn5mW3rzqqiryBkw2ptg+E1bleOGNflxtL03f1JqtUbrJ0evmHN83tH00je jPrLbifXfHciTTRzT1EAw/x+Alys9fpYnlE/c/1xEhVi8wAb7d2N+k4AsFwkSajRnLpw 92O23UdvMx2WiQy1e7cvKYC1gKAxBvfSNyPFHsOWlZaGGV7i+I8RCf5yhqWg2roHxG6r rXs6MKwFI602USITIaM7nVjAXQKm84YcFiRQoS9SRPv32uKrgblnWwud9EjEnIsERrEh txYChN8Jzewz2k8zINCDzWYDSWjDoN5816XaY84QSjI8DEjZdpWVcr2Jtd73ox490kp+ M1QQ== X-Gm-Message-State: AA+aEWZkCqZb3BoceWVeIeN5yxOQAJ6ttkpXo0sabDywN/P+NP13futJ eJ607X4q6P0W7SNavcyE4BNPCj17SZQ= X-Google-Smtp-Source: AFSGD/Xc8LAH63vkioW/smymJbxrHnVcilBXsN4hfg5YO/uJuQTqFVVCNimyRffIPaQQ5/xINmYhJA== X-Received: by 2002:a1c:7306:: with SMTP id d6mr10407719wmb.98.1544716713874; Thu, 13 Dec 2018 07:58:33 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:33 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 4/8] tests: add a check for unportable env --unset Date: Thu, 13 Dec 2018 16:58:13 +0100 Message-Id: <20181213155817.27666-5-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "env --unset=*" argument isn't portable. Neither Solaris or AIX have it, and probably not a bunch of other POSIX-like OS's. Using this was suggested on-list[1]. Let's add a check for it so it doesn't sneak into the codebase in the future. 1. https://public-inbox.org/git/cover.1544573604.git.jonathantanmy@google.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- t/check-non-portable-shell.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index b45bdac688..1cfb4608ee 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -35,6 +35,7 @@ sub err { chomp; } + /\benv (?:-u|--unset)\b/ and err 'env [-u|--unset] is not portable'; /\bsed\s+-i/ and err 'sed -i is not portable'; /\becho\s+-[neE]/ and err 'echo with option is not portable (use printf)'; /^\s*declare\s+/ and err 'arrays/declare not portable'; From patchwork Thu Dec 13 15:58:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0B0116B1 for ; Thu, 13 Dec 2018 15:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0BFD2BB53 for ; Thu, 13 Dec 2018 15:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4CCC2C139; Thu, 13 Dec 2018 15:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46D452BB53 for ; Thu, 13 Dec 2018 15:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729132AbeLMP6j (ORCPT ); Thu, 13 Dec 2018 10:58:39 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50601 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbeLMP6i (ORCPT ); Thu, 13 Dec 2018 10:58:38 -0500 Received: by mail-wm1-f67.google.com with SMTP id n190so2903226wmd.0 for ; Thu, 13 Dec 2018 07:58:36 -0800 (PST) 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=kGMlI3CZDbmq5C6f69hVH0JcGjD8Ih8XblrlBYwNo7U=; b=FSbELAXhYc0iUGnxCz0TdpP6JAJCHtYmbmgmCJ/XwUfxdiyXcQjX+izgoY8GY1NNcK PAH6yMuTJWk1r1hOrmW24GgVJSG+o8EzcNYD5TLUId4gsy8zDFanKQd1CfyMIzkDDnl4 /bcCJtVrwVwhxHXkbFt1ALd1s2qd0213lZujT+Gt9DRzfFghVVv/2jxgy+/KRcLgKgtI sBi/De1MQVvyfn/aAufcOGdl0BQaHyT5HLmyE5u87/EPmeZ1qNwNGynYbrH8YKXMhnsP LyVXPqlFG3DUeczZnRkc3p2/ZcoJjZf5XwlSQwP7lmS7OiLA6WP+yd6KNJx8Q3yZEyj0 wGog== 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=kGMlI3CZDbmq5C6f69hVH0JcGjD8Ih8XblrlBYwNo7U=; b=G8u/BSbwZZCbTKf3R9eCn8Ldu0fOyOeBaxIDSsQLz2kUdnfNSw8SZ716BsDblC2TwO NplNpbrAsy3I4nSJmTpPjtSywp8Oqcsd/kD+nt4rs4Fmq77F9WW7xjJ3FxdJ9yZXrO8N Dn/IstO53M1Bqn9/mfwWoS1Nw1VyPgvns1Luu1Ski8JyJezoHP6h8G4b9gFeZPlVnfQC 9KdGWvozsYXtGBztfKj3P+LCwjSR5qHPT9b7D1blr2MAULa2GS+gruI9axU5x+xBOl2A EBmmm3v11H5XehTiz0A/788yt2gnkIjkB/Dq3OewgBZZ7cTkG9k/jV5G+DToRiSagA1i 99TQ== X-Gm-Message-State: AA+aEWaGddAzbu2qkXrSfdmVocUkxDg5W5139CtnwA7FWlVn4NIipX2T q4Q5q2n0seQwtBjzEnQeAPad42yghbc= X-Google-Smtp-Source: AFSGD/Vknf5MzUkGHX3eFX2A7BsCL+RVJpOcElMazrIc7+kJc9Gb6gdJxVQEa0Rjx1/KMR5Iyd4fbg== X-Received: by 2002:a1c:cc19:: with SMTP id h25mr10654320wmb.80.1544716715600; Thu, 13 Dec 2018 07:58:35 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:35 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 5/8] tests: add a special setup where for protocol.version Date: Thu, 13 Dec 2018 16:58:14 +0100 Message-Id: <20181213155817.27666-6-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a GIT_TEST_PROTOCOL_VERSION=X test mode which is equivalent to running with protocol.version=X. This is needed to spot regressions and differences such as "ls-refs" behaving differently with transfer.hideRefs. See https://public-inbox.org/git/20181211104236.GA6899@sigill.intra.peff.net/ for a fix for that regression. With this all tests pass with GIT_TEST_PROTOCOL_VERSION=0, but fail with GIT_TEST_PROTOCOL_VERSION=[1|2]. That's OK since this is a new test mode, subsequent patches will fix up these test failures. Signed-off-by: Ævar Arnfjörð Bjarmason --- protocol.c | 13 ++++++++++++- t/README | 6 ++++++ t/t0410-partial-clone.sh | 3 ++- t/t5516-fetch-push.sh | 3 ++- t/t5700-protocol-v1.sh | 1 + t/t5702-protocol-v2.sh | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/protocol.c b/protocol.c index 5e636785d1..aa06c3b5bc 100644 --- a/protocol.c +++ b/protocol.c @@ -17,7 +17,18 @@ static enum protocol_version parse_protocol_version(const char *value) enum protocol_version get_protocol_version_config(void) { const char *value; - if (!git_config_get_string_const("protocol.version", &value)) { + const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION"; + const char *git_test_v = getenv(git_test_k); + + if (git_test_v && strlen(git_test_v)) { + enum protocol_version version = parse_protocol_version(git_test_v); + + if (version == protocol_unknown_version) + die("unknown value for %s: %s", git_test_k, + git_test_v); + + return version; + } else if (!git_config_get_string_const("protocol.version", &value)) { enum protocol_version version = parse_protocol_version(value); if (version == protocol_unknown_version) diff --git a/t/README b/t/README index 28711cc508..89629c5818 100644 --- a/t/README +++ b/t/README @@ -311,6 +311,12 @@ marked strings" in po/README for details. GIT_TEST_SPLIT_INDEX= forces split-index mode on the whole test suite. Accept any boolean values that are accepted by git-config. +GIT_TEST_PROTOCOL_VERSION=<'protocol.version' config value>, when set, +runs the test suite with the given protocol.version. E.g. "0", "1" or +"2". Can be set to the empty string within tests themselves (e.g. "env +GIT_TEST_PROTOCOL_VERSION= ") to unset the value in the +environment as a workaround for "env --unset" not being portable. + GIT_TEST_FULL_IN_PACK_ARRAY= exercises the uncommon pack-objects code path where there are more than 1024 packs even if the actual number of packs in repository is below this limit. Accept diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index ba3887f178..8ba3d9b5ab 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -178,7 +178,8 @@ test_expect_success 'fetching of missing objects works with ref-in-want enabled' rm -rf repo/.git/objects/* && rm -f trace && - GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" && + GIT_TRACE_PACKET="$(pwd)/trace" env GIT_TEST_PROTOCOL_VERSION= \ + git -C repo cat-file -p "$HASH" && grep "git< fetch=.*ref-in-want" trace ' diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 37e8e80893..08cdee0b95 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1187,7 +1187,8 @@ test_expect_success 'fetch exact SHA1 in protocol v2' ' # fetching the hidden object succeeds by default # NEEDSWORK: should this match the v0 behavior instead? - git -C child fetch -v ../testrepo $the_commit:refs/heads/copy + env GIT_TEST_PROTOCOL_VERSION= \ + git -C child fetch -v ../testrepo $the_commit:refs/heads/copy ' for configallowtipsha1inwant in true false diff --git a/t/t5700-protocol-v1.sh b/t/t5700-protocol-v1.sh index ba86a44eb1..e4d375c462 100755 --- a/t/t5700-protocol-v1.sh +++ b/t/t5700-protocol-v1.sh @@ -8,6 +8,7 @@ TEST_NO_CREATE_REPO=1 # Test protocol v1 with 'git://' transport # +unset GIT_TEST_PROTOCOL_VERSION . "$TEST_DIRECTORY"/lib-git-daemon.sh start_git_daemon --export-all --enable=receive-pack daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 0f2b09ebb8..d1549f294e 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -8,6 +8,7 @@ TEST_NO_CREATE_REPO=1 # Test protocol v2 with 'git://' transport # +unset GIT_TEST_PROTOCOL_VERSION . "$TEST_DIRECTORY"/lib-git-daemon.sh start_git_daemon --export-all --enable=receive-pack daemon_parent=$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent From patchwork Thu Dec 13 15:58:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4452F91E for ; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 347E62BB53 for ; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 286832C139; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A532BB53 for ; Thu, 13 Dec 2018 15:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbeLMP6m (ORCPT ); Thu, 13 Dec 2018 10:58:42 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:32969 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729121AbeLMP6k (ORCPT ); Thu, 13 Dec 2018 10:58:40 -0500 Received: by mail-wm1-f68.google.com with SMTP id r24so14211971wmh.0 for ; Thu, 13 Dec 2018 07:58:38 -0800 (PST) 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=0KBdt/z8IEPfMKjPmxD1UysUXxIPsbP2E0o0WsZlJ0s=; b=UhJgeSI43V0x64kowtCxsqrQAPx6ADAuB4rwlT8Ny+1tHZ/Zv+Q0BdPGyjYkoGl6aJ sGVfXMIKx9gdRX6glXW17XoefyuJJTP2KZPwp4tcx8Y+wKM714lGO62nBAAodznkORCv +Di5O8jX/8mrFsyhPgJSg9DIYUlQIWIIuOfAyE5/+vITOkyu/RjJNSddzBj124OExIWK 5l4+iJ4NzzSMNcnaip9gUCRlH/5v9kOsoA1a1s2nYn7gPJPFJXhGxn335d5Pj4KgQ4SV H6KVAfNApr1smSVj/aVbU9nxH3cv9Wtx+4fwj75SgUWQ55UU131zrxNQMfdfuYWHK3dv DHAQ== 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=0KBdt/z8IEPfMKjPmxD1UysUXxIPsbP2E0o0WsZlJ0s=; b=eFj3AM/iidhzWrFEmaqLZKj/TznKi4rvKchabSpCFtVwyzVJQca76vJS6nzbQ2Li3c 0B9tCWyscjI04NjKl4OorFZbJ332xtVLICeD1Sc02YwDA+H2Q6p9Hd6GBCTvg5hWV+g7 jhwque+Twm3yqebH3i/DacTKOQSsL1WTgAaJqsTn/64+gL49HR+ZyioficdDoXo7W4Ww KqDEvaF3EssU+wOmiIyNf1WBYaMVEXufj+H0NesbE5LDOC0rlspINBwP2G9+uKWE3lv6 N747aT3ZFJIdLk3cO5IGdlN2pWlp0SmUvWcKzHfHmxeBeEBvxqkv8gd6ECflm4OTb6hJ YslA== X-Gm-Message-State: AA+aEWZaffW+pL+oVZO0YFkU750S9W6tSt+T07rO0PZynJs4rgDXBZw0 VHa/jmRHtJzWyGMCGr9t3NXrgwwAJFo= X-Google-Smtp-Source: AFSGD/Xnq4463lJPNBLPnUSPZuhi9NdktYKmqZscKJ8NdXgV85WJJwtyuOxmmLIaPYgUcSHtOqOtzQ== X-Received: by 2002:a1c:13d1:: with SMTP id 200mr10597242wmt.4.1544716717327; Thu, 13 Dec 2018 07:58:37 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:36 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 6/8] tests: mark & fix tests broken under GIT_TEST_PROTOCOL_VERSION=1 Date: Thu, 13 Dec 2018 16:58:15 +0100 Message-Id: <20181213155817.27666-7-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's one t5400-send-pack.sh test which is broken under GIT_TEST_PROTOCOL_VERSION=1. It's easier to just coerce it to run under protocol 1. The difference in the output is that there'll be a "version 1" line which'll make the subsequent "test_cmp". See protocol.version in git-config(1) which notes that "1" is just "0" with a version number. the trace output will include fail. Similarly in t5601-clone.sh we'll be passing an option to ssh, but since so many tests would fail in this file let's go above & beyond and make them pass by only testing the relevant part of the output. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t5400-send-pack.sh | 2 +- t/t5601-clone.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index f1932ea431..571d620aed 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -288,7 +288,7 @@ test_expect_success 'receive-pack de-dupes .have lines' ' $shared .have EOF - GIT_TRACE_PACKET=$(pwd)/trace \ + GIT_TRACE_PACKET=$(pwd)/trace GIT_TEST_PROTOCOL_VERSION= \ git push \ --receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \ fork HEAD:foo && diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh index 8bbc7068ac..a7b7ab327c 100755 --- a/t/t5601-clone.sh +++ b/t/t5601-clone.sh @@ -325,7 +325,7 @@ copy_ssh_wrapper_as () { expect_ssh () { test_when_finished ' - (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output) + (cd "$TRASH_DIRECTORY" && rm -f ssh-expect ssh-output.munged && >ssh-output) ' && { case "$#" in @@ -341,7 +341,14 @@ expect_ssh () { echo "ssh: $1 $2 git-upload-pack '$3' $4" esac } >"$TRASH_DIRECTORY/ssh-expect" && - (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output) + ( + cd "$TRASH_DIRECTORY" && + # We don't care about this trivial difference in + # output with GIT_TEST_PROTOCOL_VERSION=[12] + sed 's/ssh: -o SendEnv=GIT_PROTOCOL /ssh: /' ssh-output.munged && + mv ssh-output.munged ssh-output && + test_cmp ssh-expect ssh-output + ) } test_expect_success 'clone myhost:src uses ssh' ' From patchwork Thu Dec 13 15:58:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D801416B1 for ; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C60072BB53 for ; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA8352C139; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68D242BB53 for ; Thu, 13 Dec 2018 15:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729145AbeLMP6m (ORCPT ); Thu, 13 Dec 2018 10:58:42 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52419 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbeLMP6l (ORCPT ); Thu, 13 Dec 2018 10:58:41 -0500 Received: by mail-wm1-f67.google.com with SMTP id m1so2884495wml.2 for ; Thu, 13 Dec 2018 07:58:40 -0800 (PST) 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=EpzIcC4gmhmYqL5ckoFLkikS8r+/HeNlLvhyavD1tF4=; b=qEobOcO0SoqTGnc0gotoYG8op2dWr6bHF2cxK8OhoivCdZ8fDRFoJAudXIoAP+SMRU YUio723TBcTXolSSVYDQNxdmyXdbbTecvrO4m5Na+pLQmVEwblX7/FuPrwIJ13/yT/uM PgVWV1x5DbXsBp9UQMV2jAd985FuoqcIZLH3xs3lPxYuv3T68eIVVf+2TMx6/RyUthiE ORszgZnhpoijr+uxTwPpLhBmwvvMH3iz5FIOZsPQeW2hOMCWaADaZ72Uhnkqp0NhtP5Q 5L/dDekwb83azcbrjGkrIgYxjPqBz3gHnHzcOG8PiVPqnDVMEvEEbXFbpFTLTXFTw/Kl 1UPw== 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=EpzIcC4gmhmYqL5ckoFLkikS8r+/HeNlLvhyavD1tF4=; b=Bt/hUPVpWCWIBRsrDr8L6abIqiAUjjLStaGMOcNU8xFqWIWbKpRsG8CgTjKqkd/EPp RpIGk90NbiRn8OdNVCyk2KIGwgXuyiJyt5vVlxWZCGGh++OT0L1ZGyfBJixmhDumAwsr Z5EkOk2B2BaHRRWdKyYYhrrd0cSS8pJYM1PY5jbEAsSDPFtsocRZ/gX0RCpQgkgx7by6 5GUz2zMTzt8QPZxwrFqWlvi36BLc9frMXG9s+MqXbzzhp8M/248n8gAsip28DLZnZZ+o lnCb1CUFPPGEJ25pEXIbHL60MmzkD6EKyFntgfOSSzjEB9JLltk5VtAz8fsK2H46u8Fh UcqQ== X-Gm-Message-State: AA+aEWbVa7KPze9VXx9NHNtJIjijf5IalILOWHYhYgp8Rz+OFQDYAKkj FT+y0UZaSLLUFoJ7vS7pxU/24q9w1Oo= X-Google-Smtp-Source: AFSGD/VdgsXha5rCpzN41ZfOMBbVvCV1hfcdcmlU0tfnO1kmwJ/0ftbQ5ubYxGJRfy4qd/LTNCc20Q== X-Received: by 2002:a1c:90d5:: with SMTP id s204mr10724153wmd.148.1544716719203; Thu, 13 Dec 2018 07:58:39 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:38 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 7/8] builtin/fetch-pack: support protocol version 2 Date: Thu, 13 Dec 2018 16:58:16 +0100 Message-Id: <20181213155817.27666-8-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jonathan Tan Currently, if support for running Git's entire test suite with protocol v2 were added, some tests would fail because the fetch-pack CLI command dies if it encounters protocol v2. To avoid this, teach fetch-pack support for protocol v2. Signed-off-by: Jonathan Tan Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fetch-pack.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 63e69a5801..f6a513495e 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -55,6 +55,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) struct oid_array shallow = OID_ARRAY_INIT; struct string_list deepen_not = STRING_LIST_INIT_DUP; struct packet_reader reader; + enum protocol_version version; fetch_if_missing = 0; @@ -219,9 +220,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) PACKET_READ_CHOMP_NEWLINE | PACKET_READ_GENTLE_ON_EOF); - switch (discover_version(&reader)) { + version = discover_version(&reader); + switch (version) { case protocol_v2: - die("support for protocol v2 not implemented yet"); + get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL); + break; case protocol_v1: case protocol_v0: get_remote_heads(&reader, &ref, 0, NULL, &shallow); @@ -231,7 +234,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) } ref = fetch_pack(&args, fd, conn, ref, dest, sought, nr_sought, - &shallow, pack_lockfile_ptr, protocol_v0); + &shallow, pack_lockfile_ptr, version); if (pack_lockfile) { printf("lock %s\n", pack_lockfile); fflush(stdout); From patchwork Thu Dec 13 15:58:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10729053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0F7491E for ; Thu, 13 Dec 2018 15:58:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA2E2C342 for ; Thu, 13 Dec 2018 15:58:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D36F82C33F; Thu, 13 Dec 2018 15:58:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80E672C33F for ; Thu, 13 Dec 2018 15:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729176AbeLMP6q (ORCPT ); Thu, 13 Dec 2018 10:58:46 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:51936 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729134AbeLMP6o (ORCPT ); Thu, 13 Dec 2018 10:58:44 -0500 Received: by mail-wm1-f49.google.com with SMTP id s14so2891521wmh.1 for ; Thu, 13 Dec 2018 07:58:42 -0800 (PST) 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=5gQ2mv/zEkDBYk974b7TxPaXjUo+AkxMZ6OkiN36Iu8=; b=pjrfLPrJLk87SRrGesR8CLkHkFY2IlWaFucBU38CihK/CBx2F1My42uhxtxv6ROGud 1bpMHIX7p14ph0APE3h5d3cFs2QjNU3+ZjYa8ZyoZc5ixjNp9Ne4C18O3t8DPZBVfRHO 6mIFZMsix6kdghzPA/obYysxXcP5gMA6idA40I9FqCQOXHPvkB33zR8HTdzudNMPzXGw IjRUDKwfEFEbybPIgaFkKJ+Gx01+GK+JJx+XKHJuActGK1dn8w8X4y5UvYzSqgZ8/G7s t2/Vgn/qj9YF2i35uGHHym81ZXYchQAiLcEylyKJHfj1vSbO5I84vrRPAM7byL722X/V dg5Q== 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=5gQ2mv/zEkDBYk974b7TxPaXjUo+AkxMZ6OkiN36Iu8=; b=aXEd6Z6rOmpzdgWUdoP0+eL4F0M4vTduu2y9+LevOdI0OAczyh9Ujdr1ZeRRVeS6Fr zEbo64J4IVd3tl93FkpIsLjA5RX9Rd8Wsj938/DWD92ZQNkfcBRp09V1OxFvyUHYrhya 8jRwPGpCWsMYxuwJgB0KXlgFUbUBmW7YdjKnMQDBcif6juk4M4cZU2E10RI1wJVtQKJM b+hhE+LcCta4/6nPe3gu1oDdP3P963SxIA8BOIlWyLVwamLjklIs3JXctW5o9GQpuI9I uZH7yjn0gZS+vCa/IuktVOeQe5t2okzrZ7hh60PUnXOaJaLraoDccb406F3cyf/CAbgs BuUA== X-Gm-Message-State: AA+aEWbehOEK40ovKro+hU3Hx6+yBQwRifnCs/qUHNbUmUew6PQEaK6w SxkkDQDOAkdvBLp/n39eKfy4CxKdqo4= X-Google-Smtp-Source: AFSGD/XK2zdF367iB7GJChzv7AnsVFynZiACgekyyAuP4mC+Hn7tn0yv2vTOYI3DaSozF9XViCFQjg== X-Received: by 2002:a1c:d1cd:: with SMTP id i196mr9027779wmg.107.1544716720952; Thu, 13 Dec 2018 07:58:40 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r69sm4047821wmd.4.2018.12.13.07.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Dec 2018 07:58:40 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v2 8/8] tests: mark tests broken under GIT_TEST_PROTOCOL_VERSION=2 Date: Thu, 13 Dec 2018 16:58:17 +0100 Message-Id: <20181213155817.27666-9-avarab@gmail.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Mark those tests that have behavior differences or bugs under protocol.version=2. Whether or not these tests should exhibit different behavior is outside the scope of this change. Some (such as t5500-fetch-pack.sh) are intentionally different, but others (such as t7406-submodule-update.sh and t5515-fetch-merge-logic.sh) might indicate bugs in the protocol v2 code. Tracking down which is which is outside the scope of this change. Let's first exhaustively annotate where the differences are, so that we can spot future behavior differences or regressions. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Jonathan Tan --- t/t5500-fetch-pack.sh | 9 ++++++--- t/t5503-tagfollow.sh | 8 ++++---- t/t5512-ls-remote.sh | 8 ++++---- t/t5515-fetch-merge-logic.sh | 2 +- t/t5516-fetch-push.sh | 17 +++++++++++------ t/t5537-fetch-shallow.sh | 3 ++- t/t5539-fetch-http-shallow.sh | 9 +++++---- t/t5541-http-push-smart.sh | 9 +++++++-- t/t5551-http-fetch-smart.sh | 19 +++++++++++-------- t/t5552-skipping-fetch-negotiator.sh | 4 ++-- t/t5570-git-daemon.sh | 2 +- t/t7406-submodule-update.sh | 3 ++- 12 files changed, 56 insertions(+), 37 deletions(-) diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 086f2c40f6..8b1217ea26 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -628,7 +628,10 @@ test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised a test_commit -C server 6 && git init client && - test_must_fail git -C client fetch-pack ../server \ + + # Other protocol versions (e.g. 2) allow fetching an unadvertised + # object, so run this test with the default protocol version (0). + test_must_fail env GIT_TEST_PROTOCOL_VERSION= git -C client fetch-pack ../server \ $(git -C server rev-parse refs/heads/master^) 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err ' @@ -788,7 +791,7 @@ test_expect_success 'shallow clone exclude tag two' ' ' test_expect_success 'fetch exclude tag one' ' - git -C shallow12 fetch --shallow-exclude one origin && + GIT_TEST_PROTOCOL_VERSION= git -C shallow12 fetch --shallow-exclude one origin && git -C shallow12 log --pretty=tformat:%s origin/master >actual && test_write_lines three two >expected && test_cmp expected actual @@ -806,7 +809,7 @@ test_expect_success 'fetching deepen' ' git -C deepen log --pretty=tformat:%s master >actual && echo three >expected && test_cmp expected actual && - git -C deepen fetch --deepen=1 && + GIT_TEST_PROTOCOL_VERSION= git -C deepen fetch --deepen=1 && git -C deepen log --pretty=tformat:%s origin/master >actual && cat >expected <<-\EOF && four diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh index 4ca48f0276..0e90a90294 100755 --- a/t/t5503-tagfollow.sh +++ b/t/t5503-tagfollow.sh @@ -56,7 +56,7 @@ test_expect_success 'fetch A (new commit : 1 connection)' ' rm -f $U && ( cd cloned && - GIT_TRACE_PACKET=$UPATH git fetch && + GIT_TRACE_PACKET=$UPATH GIT_TEST_PROTOCOL_VERSION= git fetch && test $A = $(git rev-parse --verify origin/master) ) && get_needs $U >actual && @@ -86,7 +86,7 @@ test_expect_success 'fetch C, T (new branch, tag : 1 connection)' ' rm -f $U && ( cd cloned && - GIT_TRACE_PACKET=$UPATH git fetch && + GIT_TRACE_PACKET=$UPATH GIT_TEST_PROTOCOL_VERSION= git fetch && test $C = $(git rev-parse --verify origin/cat) && test $T = $(git rev-parse --verify tag1) && test $A = $(git rev-parse --verify tag1^0) @@ -122,7 +122,7 @@ test_expect_success 'fetch B, S (commit and tag : 1 connection)' ' rm -f $U && ( cd cloned && - GIT_TRACE_PACKET=$UPATH git fetch && + GIT_TRACE_PACKET=$UPATH GIT_TEST_PROTOCOL_VERSION= git fetch && test $B = $(git rev-parse --verify origin/master) && test $B = $(git rev-parse --verify tag2^0) && test $S = $(git rev-parse --verify tag2) @@ -146,7 +146,7 @@ test_expect_success 'new clone fetch master and tags' ' cd clone2 && git init && git remote add origin .. && - GIT_TRACE_PACKET=$UPATH git fetch && + GIT_TRACE_PACKET=$UPATH GIT_TEST_PROTOCOL_VERSION= git fetch && test $B = $(git rev-parse --verify origin/master) && test $S = $(git rev-parse --verify tag2) && test $B = $(git rev-parse --verify tag2^0) && diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index ca69636fd5..7b480587c9 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -223,7 +223,7 @@ test_expect_success 'ls-remote --symref' ' $(git rev-parse refs/tags/mark1.10) refs/tags/mark1.10 $(git rev-parse refs/tags/mark1.2) refs/tags/mark1.2 EOF - git ls-remote --symref >actual && + GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref >actual && test_cmp expect actual ' @@ -243,7 +243,7 @@ test_expect_failure 'ls-remote with filtered symref (--heads)' ' 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master EOF - git ls-remote --symref --heads . >actual && + GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual && test_cmp expect actual ' @@ -252,9 +252,9 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' ' 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/foo 1bd44cb9d13204b0fe1958db0082f5028a16eb3a refs/heads/master EOF - git ls-remote --symref --heads . >actual && + GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref --heads . >actual && test_cmp expect actual && - git ls-remote --symref . "refs/heads/*" >actual && + GIT_TEST_PROTOCOL_VERSION= git ls-remote --symref . "refs/heads/*" >actual && test_cmp expect actual ' diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh index 36b0dbc01c..f095555c3e 100755 --- a/t/t5515-fetch-merge-logic.sh +++ b/t/t5515-fetch-merge-logic.sh @@ -147,7 +147,7 @@ do do git update-ref -d "$refname" "$val" done - git fetch "$@" >/dev/null + GIT_TEST_PROTOCOL_VERSION= git fetch "$@" >/dev/null cat .git/FETCH_HEAD } >"$actual_f" && git show-ref >"$actual_r" && diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 08cdee0b95..1d1b717cd5 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1129,7 +1129,7 @@ do ' done -test_expect_success 'fetch exact SHA1' ' +test_expect_success 'fetch exact SHA1 in protocol v0' ' mk_test testrepo heads/master hidden/one && git push testrepo master:refs/hidden/one && ( @@ -1148,7 +1148,8 @@ test_expect_success 'fetch exact SHA1' ' test_must_fail git cat-file -t $the_commit && # fetching the hidden object should fail by default - test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err && + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + git fetch -v ../testrepo $the_commit:refs/heads/copy 2>err && test_i18ngrep "Server does not allow request for unadvertised object" err && test_must_fail git rev-parse --verify refs/heads/copy && @@ -1205,7 +1206,8 @@ do mk_empty shallow && ( cd shallow && - test_must_fail git fetch --depth=1 ../testrepo/.git $SHA1 && + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + git fetch --depth=1 ../testrepo/.git $SHA1 && git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true && git fetch --depth=1 ../testrepo/.git $SHA1 && git cat-file commit $SHA1 @@ -1233,15 +1235,18 @@ do mk_empty shallow && ( cd shallow && - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3 && - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_1 && + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \ + git fetch ../testrepo/.git $SHA1_3 && + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \ + git fetch ../testrepo/.git $SHA1_1 && git --git-dir=../testrepo/.git config uploadpack.allowreachablesha1inwant true && git fetch ../testrepo/.git $SHA1_1 && git cat-file commit $SHA1_1 && test_must_fail git cat-file commit $SHA1_2 && git fetch ../testrepo/.git $SHA1_2 && git cat-file commit $SHA1_2 && - test_must_fail ok=sigpipe git fetch ../testrepo/.git $SHA1_3 + test_must_fail ok=sigpipe env GIT_TEST_PROTOCOL_VERSION= \ + git fetch ../testrepo/.git $SHA1_3 ) ' done diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index 6faf17e17a..85b3022ce6 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -127,7 +127,8 @@ test_expect_success 'fetch that requires changes in .git/shallow is filtered' ' git init notshallow && ( cd notshallow && - git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&& + GIT_TEST_PROTOCOL_VERSION= \ + git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/* && git for-each-ref --format="%(refname)" >actual.refs && cat <expect.refs && refs/remotes/shallow/no-shallow diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh index 5fbf67c446..a121e19bc7 100755 --- a/t/t5539-fetch-http-shallow.sh +++ b/t/t5539-fetch-http-shallow.sh @@ -67,7 +67,8 @@ test_expect_success 'no shallow lines after receiving ACK ready' ' cd clone && git checkout --orphan newnew && test_commit new-too && - GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch --depth=2 && + GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION= \ + git fetch --depth=2 && grep "fetch-pack< ACK .* ready" ../trace && ! grep "fetch-pack> done" ../trace ) @@ -114,7 +115,7 @@ test_expect_success 'shallow clone exclude tag two' ' ' test_expect_success 'fetch exclude tag one' ' - git -C shallow12 fetch --shallow-exclude one origin && + GIT_TEST_PROTOCOL_VERSION= git -C shallow12 fetch --shallow-exclude one origin && git -C shallow12 log --pretty=tformat:%s origin/master >actual && test_write_lines three two >expected && test_cmp expected actual @@ -128,14 +129,14 @@ test_expect_success 'fetching deepen' ' test_commit two && test_commit three && mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" && - git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen && + GIT_TEST_PROTOCOL_VERSION= git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen && mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git && test_commit four && git -C deepen log --pretty=tformat:%s master >actual && echo three >expected && test_cmp expected actual && mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" && - git -C deepen fetch --deepen=1 && + GIT_TEST_PROTOCOL_VERSION= git -C deepen fetch --deepen=1 && git -C deepen log --pretty=tformat:%s origin/master >actual && cat >expected <<-\EOF && four diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 5475afc052..180c9005b7 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -45,14 +45,19 @@ test_expect_success 'no empty path components' ' # In the URL, add a trailing slash, and see if git appends yet another # slash. cd "$ROOT_PATH" && - git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone && + # Other protocol versions may make different requests, so perform this + # clone with the default protocol. + GIT_TEST_PROTOCOL_VERSION= git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone && check_access_log exp ' test_expect_success 'clone remote repository' ' rm -rf test_repo_clone && - git clone $HTTPD_URL/smart/test_repo.git test_repo_clone && + # Other protocol versions may make different requests, so perform this + # clone with the default protocol. + GIT_TEST_PROTOCOL_VERSION= git clone $HTTPD_URL/smart/test_repo.git test_repo_clone && + ( cd test_repo_clone && git config push.default matching ) diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index 8630b0cc39..a51993f35a 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -43,7 +43,8 @@ test_expect_success 'clone http repository' ' < Cache-Control: no-cache, max-age=0, must-revalidate < Content-Type: application/x-git-upload-pack-result EOF - GIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err && + GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION= \ + git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err && test_cmp file clone/file && tr '\''\015'\'' Q >file && git commit -a -m two && git push public && - (cd clone && git pull) && + (cd clone && GIT_TEST_PROTOCOL_VERSION= git pull) && test_cmp file clone/file ' @@ -143,7 +144,7 @@ test_expect_success 'clone from auth-only-for-push repository' ' test_expect_success 'clone from auth-only-for-objects repository' ' echo two >expect && set_askpass user@host pass@host && - git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth && + GIT_TEST_PROTOCOL_VERSION= git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth && expect_askpass both user@host && git --git-dir=half-auth log -1 --format=%s >actual && test_cmp expect actual @@ -151,7 +152,7 @@ test_expect_success 'clone from auth-only-for-objects repository' ' test_expect_success 'no-op half-auth fetch does not require a password' ' set_askpass wrong && - git --git-dir=half-auth fetch && + GIT_TEST_PROTOCOL_VERSION= git --git-dir=half-auth fetch && expect_askpass none ' @@ -187,7 +188,7 @@ test_expect_success 'create namespaced refs' ' ' test_expect_success 'smart clone respects namespace' ' - git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart && + GIT_TEST_PROTOCOL_VERSION= git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart && echo namespaced >expect && git --git-dir=ns-smart/.git log -1 --format=%s >actual && test_cmp expect actual @@ -214,7 +215,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set EOF git config http.cookiefile cookies.txt && git config http.savecookies true && - git ls-remote $HTTPD_URL/smart_cookies/repo.git master && + GIT_TEST_PROTOCOL_VERSION= git ls-remote $HTTPD_URL/smart_cookies/repo.git master && tail -3 cookies.txt | sort >cookies_tail.txt && test_cmp expect_cookies.txt cookies_tail.txt ' @@ -306,7 +307,8 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' ' git init --bare test_reachable.git && git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && - test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" ' test_expect_success 'test allowanysha1inwant with unreachable' ' @@ -325,7 +327,8 @@ test_expect_success 'test allowanysha1inwant with unreachable' ' git init --bare test_reachable.git && git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && - test_must_fail git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" && + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" && git -C "$server" config uploadpack.allowanysha1inwant 1 && git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index 30857b84a8..979e6583d4 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -127,7 +127,7 @@ test_expect_success 'use ref advertisement to filter out commits' ' # not need to send any ancestors of "c3", but we still need to send "c3" # itself. test_config -C client fetch.negotiationalgorithm skipping && - trace_fetch client origin to_fetch && + GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch && have_sent c5 c4^ c2side && have_not_sent c4 c4^^ c4^^^ ' @@ -189,7 +189,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC test_commit -C server commit-on-b1 && test_config -C client fetch.negotiationalgorithm skipping && - trace_fetch client "$(pwd)/server" to_fetch && + GIT_TEST_PROTOCOL_VERSION= trace_fetch client "$(pwd)/server" to_fetch && grep " fetch" trace && # fetch-pack sends 2 requests each containing 16 "have" lines before diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index 7466aad111..c42ee245cd 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -190,7 +190,7 @@ test_expect_success 'daemon log records all attributes' ' EOF >daemon.log && GIT_OVERRIDE_VIRTUAL_HOST=localhost \ - git -c protocol.version=1 \ + GIT_TEST_PROTOCOL_VERSION= git -c protocol.version=1 \ ls-remote "$GIT_DAEMON_URL/interp.git" && grep -i extended.attribute daemon.log | cut -d" " -f2- >actual && test_cmp expect actual diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index e87164aa8f..a555e38845 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -943,7 +943,8 @@ test_expect_success 'submodule update clone shallow submodule outside of depth' cd super3 && sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp && mv -f .gitmodules.tmp .gitmodules && - test_must_fail git submodule update --init --depth=1 2>actual && + test_must_fail env GIT_TEST_PROTOCOL_VERSION= \ + git submodule update --init --depth=1 2>actual && test_i18ngrep "Direct fetching of that commit failed." actual && git -C ../submodule config uploadpack.allowReachableSHA1InWant true && git submodule update --init --depth=1 >actual &&