From patchwork Mon Dec 5 17:50:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 13064942 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 47836C4332F for ; Mon, 5 Dec 2022 17:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229471AbiLERwe (ORCPT ); Mon, 5 Dec 2022 12:52:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232766AbiLERvl (ORCPT ); Mon, 5 Dec 2022 12:51:41 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6CD7625E for ; Mon, 5 Dec 2022 09:50:48 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id h7so13796424wrs.6 for ; Mon, 05 Dec 2022 09:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CnzbZmXRCbIZiehAtyBacIrTHxr9bywfhJLnH/5Lu34=; b=YPKpt9YFyKFYvLhkHusCQkhW1QiOdA+XqwmzB23ps0SXsQMHjRicZABLSCy6PT7Dxb fbrEdx7AJCNXafMKHpdJgxRpixore5YuRxazlbGOtaahQ7JmzG+vJeEwvMiA5bJ7f//Z W8KDTeGsZsuukssuvT2UpyoZuCZcDgudsVNOn/FZ4p2ePulrD+6NQUI145Rjmxkh0QfU acwtDAaEgotzJuEe1G0iscgRjF0BYCJCFPM/J862Psd7gzehXUUHIVlgNuCloO0xrbCe 2EhNvzBLnMsuQZbxTqU1mfppGXt9saKUOrtvg7TH8cKE9/ZM8Bxwx11pQtaMu4eDKGIQ DtYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CnzbZmXRCbIZiehAtyBacIrTHxr9bywfhJLnH/5Lu34=; b=g3Qi7OmPlMnVjy28fBEHvF0VXwLna+tV561oK9aBHwn6RXMmBP9xeqCKgJmey6gNpp D7n6UkK8b0c0Ru3oe8JdJnd8+1FLOsC5Os5xssGJ/Jn6WNV88tCrNQMWikcrg8+NHwBE /nTjk8zF1Lq9xDi6WZK8ZEwhxPP2X06FVIzP6RV2LaKqi8Y5Uf0idaW7zidLO1YtW/Ut f+JXxQzTkhjigbITGzHjAv6KhPOpDCyyPWft2aUmMtnbxppwvnhiLhQvMOn38gr9p91v DUz500R9ooxyt01cxbRFTAgQiNOYsWlmbYttYr0C7qK42RQKv2o770JA+gQULoapxqQF LIJw== X-Gm-Message-State: ANoB5pkrwaG1uQHnL0Skui/V8kML/yVhPej9Yvp7oacqLEKIwsVLarcV Lom5wBXeFQ6IdrjMT7/FzPNfDU5k0C8= X-Google-Smtp-Source: AA0mqf744g28B8P4z1DxGQIOp8dBh73g8SIHCWBHfGkKYK0BzeQ+tb2VUsDTBcvsseHdBkkkfKCxAg== X-Received: by 2002:adf:ce06:0:b0:242:436e:c69a with SMTP id p6-20020adfce06000000b00242436ec69amr9424661wrn.631.1670262647006; Mon, 05 Dec 2022 09:50:47 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v6-20020adfe286000000b00241f467f888sm14758952wri.74.2022.12.05.09.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 09:50:46 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 05 Dec 2022 17:50:35 +0000 Subject: [PATCH v3 07/11] bundle-uri: serve bundle.* keys from config Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, newren@gmail.com, avarab@gmail.com, mjcheetham@outlook.com, steadmon@google.com, chooglen@google.com, jonathantanmy@google.com, dyroneteng@gmail.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Implement the "bundle-uri" protocol v2 capability by populating the key=value packet lines from the local Git config. The list of bundles is provided from the keys beginning with "bundle.". In the future, we may want to filter this list to be more specific to the exact known keys that the server intends to share, but for flexibility at the moment we will assume that the config values are well-formed. Signed-off-by: Derrick Stolee --- bundle-uri.c | 16 +++++++++++++++- t/lib-bundle-uri-protocol.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/bundle-uri.c b/bundle-uri.c index 32022595964..6919f541085 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -581,6 +581,16 @@ cached: return advertise_bundle_uri; } +static int config_to_packet_line(const char *key, const char *value, void *data) +{ + struct packet_reader *writer = data; + + if (!strncmp(key, "bundle.", 7)) + packet_write_fmt(writer->fd, "%s=%s", key, value); + + return 0; +} + int bundle_uri_command(struct repository *r, struct packet_reader *request) { @@ -592,7 +602,11 @@ int bundle_uri_command(struct repository *r, if (request->status != PACKET_READ_FLUSH) die(_("bundle-uri: expected flush after arguments")); - /* TODO: Implement the communication */ + /* + * Read all "bundle.*" config lines to the client as key=value + * packet lines. + */ + git_config(config_to_packet_line, &writer); packet_writer_flush(&writer); diff --git a/t/lib-bundle-uri-protocol.sh b/t/lib-bundle-uri-protocol.sh index 88e339ae9ad..6d3f871fa0f 100644 --- a/t/lib-bundle-uri-protocol.sh +++ b/t/lib-bundle-uri-protocol.sh @@ -129,8 +129,11 @@ test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol [bundle] version = 1 mode = all + [bundle "only"] + uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED EOF + GIT_TEST_BUNDLE_URI=1 \ test-tool bundle-uri \ ls-remote \ "$BUNDLE_URI_REPO_URI" \ @@ -150,8 +153,40 @@ test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol [bundle] version = 1 mode = all + [bundle "only"] + uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED EOF + GIT_TEST_BUNDLE_URI=1 \ + test-tool bundle-uri \ + ls-remote \ + "$BUNDLE_URI_REPO_URI" \ + >actual && + test_cmp_config_output expect actual +' + +test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol v2 with list" ' + test_config -C "$BUNDLE_URI_PARENT" \ + bundle.bundle1.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl" && + test_config -C "$BUNDLE_URI_PARENT" \ + bundle.bundle2.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-2.bdl" && + test_config -C "$BUNDLE_URI_PARENT" \ + bundle.bundle3.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-3.bdl" && + + # All data about bundle URIs + cat >expect <<-EOF && + [bundle] + version = 1 + mode = all + [bundle "bundle1"] + uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl + [bundle "bundle2"] + uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-2.bdl + [bundle "bundle3"] + uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-3.bdl + EOF + + GIT_TEST_BUNDLE_URI=1 \ test-tool bundle-uri \ ls-remote \ "$BUNDLE_URI_REPO_URI" \