Article View: linux.kernel.git
Article #4266[PATCH v6 3/3] bundle-uri: do not die on unresolvable relative URIs
From: Aniket Gupta
Date: Wed, 02 Dec 2026 20:46
Date: Wed, 02 Dec 2026 20:46
148 lines
16565 bytes
16565 bytes
A bundle list, either advertised by a server or given to "git clone
--bundle-uri", may contain relative URIs. They are resolved with
relative_url(), which calls die() when there are more "../" components
than the base can absorb, so one bad entry aborts the whole clone.
Resolve them with relative_url_gently() instead. When that fails,
bundle_list_update() reports the problem as an error, drops the bundle,
which has no URI to use, and stops parsing the list. Dropping it keeps
the clone from complaining a second time that the bundle has no URI. A
"uri" key without a value is handled in the same way.
What happens then depends on where the list came from. For a list
advertised by a server, the bundles before the bad entry are still
used and the ones after it are not. A list given to "--bundle-uri" is
read from a file and rejected as a whole. In both cases the clone
carries on and fetches what is missing from the remote.
This resolves the TODO in t5750, so update the test to match.
Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
bundle-uri.c | 29 ++++++++++++++++++++++++++---
t/t5558-clone-bundle-uri.sh | 16 ++++++++++++++++
t/t5750-bundle-uri-parse.sh | 24 ++++++++++++++++--------
3 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/bundle-uri.c b/bundle-uri.c
index 41c817eefb..4cb5014968 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -134,6 +134,19 @@ void print_bundle_list(FILE *fp, struct bundle_list *list)
for_all_bundles_in_list(list, summarize_bundle, fp);
}
+/*
+ * Remove a bundle from the list when its URI cannot be used, so that the
+ * list does not keep an entry without a URI.
+ */
+static int drop_bundle(struct bundle_list *list,
+ struct remote_bundle_info *bundle)
+{
+ hashmap_remove(&list->bundles, &bundle->ent, NULL);
+ clear_remote_bundle_info(bundle, NULL);
+ free(bundle);
+ return -1;
+}
+
/**
* Given a key-value pair, update the state of the given bundle list.
* Returns 0 if the key-value pair is understood. Returns -1 if the key
@@ -214,11 +227,21 @@ static int bundle_list_update(const char *key, const char *value,
strbuf_release(&id);
if (!strcmp(subkey, "uri")) {
- if (!value)
- return config_error_nonbool(key);
+ struct strbuf err = STRBUF_INIT;
+
+ if (!value) {
+ config_error_nonbool(key);
+ return drop_bundle(list, bundle);
+ }
if (bundle->uri)
return -1;
- bundle->uri = relative_url(list->baseURI, value, NULL);
+ bundle->uri = relative_url_gently(list->baseURI, value, NULL,
+ &err);
+ if (!bundle->uri) {
+ error("%s", err.buf);
+ strbuf_release(&err);
+ return drop_bundle(list, bundle);
+ }
return 0;
}
diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh
index e86ed7d30c..e7a3e17775 100755
--- a/t/t5558-clone-bundle-uri.sh
+++ b/t/t5558-clone-bundle-uri.sh
@@ -1351,6 +1351,22 @@ test_expect_success 'bundles advertised with empty URI' '
test_grep ! "expected packfile" err
'
+test_expect_success 'bundles advertised with unresolvable relative URI' '
+ git clone --no-local --mirror clone-from \
+ "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" config uploadpack.advertiseBundleURIs true &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" config bundle.version 1 &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" config bundle.mode all &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" config bundle.bundle-1.uri ../../../../../../../../bundle.bdl &&
+ git -C "$HTTPD_DOCUMENT_ROOT_PATH/bad-relative-uri.git" config bundle.bundle-1.creationToken 1 &&
+
+ git -c transfer.bundleURI=true clone \
+ "$HTTPD_URL/smart/bad-relative-uri.git" target-bad-relative-uri 2>err &&
+ test_grep "cannot strip one component off url" err &&
+ test_grep ! "has no uri" err &&
+ git -C target-bad-relative-uri fsck
+'
+
# Do not add tests here unless they use the HTTP server, as they will
# not run unless the HTTP dependencies exist.
diff --git a/t/t5750-bundle-uri-parse.sh b/t/t5750-bundle-uri-parse.sh
index a91c1b428d..f035fc99a7 100755
--- a/t/t5750-bundle-uri-parse.sh
+++ b/t/t5750-bundle-uri-parse.sh
@@ -68,17 +68,16 @@ test_expect_success 'bundle_uri_parse_line(): relative URIs and parent paths' '
uri = <uri>/bundle.bdl
[bundle "two"]
uri = bundle.bdl
- [bundle "three"]
- uri = <uri>/../bundle.bdl
EOF
- # TODO: We would prefer if parsing a bundle list would not cause
- # a die() and instead would give a warning and allow the rest of
- # a Git command to continue. This test_must_fail is necessary for
- # now until the interface for relative_url() allows for reporting
- # an error instead of die()ing.
+ cat >err.expect <<-\EOF &&
+ error: cannot strip one component off url '\''<uri>'\''
+ error: bad line: '\''bundle.three.uri=../../bundle.bdl'\''
+ EOF
+
test_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&
- test_grep "fatal: cannot strip one component off url" err
+ test_cmp err.expect err &&
+ test_cmp_config_output expect actual
'
test_expect_success 'bundle_uri_parse_line() parsing edge cases: empty key or value' '
@@ -328,4 +327,13 @@ test_expect_success 'parse config format edge cases: keys without a value' '
done
'
+test_expect_success 'parse config format edge cases: a uri without a value drops the bundle' '
+ printf "[bundle]\n\tversion = 1\n\tmode = all\n[bundle \"one\"]\n\turi\n" >input &&
+
+ test_must_fail test-tool bundle-uri parse-config input >actual 2>err &&
+ test_grep "missing value for .bundle.one.uri." err &&
+ test_grep "mode = all" actual &&
+ test_grep ! "bundle .one." actual
+'
+
test_done
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261202204608.97770-4-aniketgupta3001@gmail.com>Path:
mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76903-linux-kernel-git=dewy.ruReferences:
<20261105152842.566318-1-aniketgupta3001@gmail.com> <20261126115803.30015-1-aniketgupta3001@gmail.com> <20261202204608.97770-1-aniketgupta3001@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-sfo.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76903-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: [PATCH v6 3/3] bundle-uri: do not die on unresolvable relative URIs
Date: Thu, 3 Dec 2026 02:16:08 +0530
Organization: Usenet Network
Message-ID: <20261202204608.97770-4-aniketgupta3001@gmail.com>
References: <20261105152842.566318-1-aniketgupta3001@gmail.com> <20261126115803.30015-1-aniketgupta3001@gmail.com>
<20261202204608.97770-1-aniketgupta3001@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2056429"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XrG1EFm4e9RD4Mu2buWQQgJ9BCo= sha256:YsEBDYUBbijqA2F2vdy9FKAsj4CK5eJ+sRuvVv8F+Cw=
sha1:Ea1kl0zsjzaP7lVQ3KBrn+/U8WM= sha256:RiBtgbM829qp3EXNOydHYlDug1Z5gBxKStgAamtCRFo=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 7F6B411771F; Wed, 2 Dec 2026 23:46:38 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id VNkWVVr7rFfM;
Wed, 2 Dec 2026 23:46:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76903-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id C143C1176E7; Wed, 2 Dec 2026 23:46:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id A3F5C2B34C; Wed, 2 Dec 2026 20:46:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796244384;
b=lSgrGvLxcvXyFKU3Dyc9q4XsN+nAAkBXdYdED4NRVScDcOrYikwPVKS/Lup2NGokym/9
5RckTZ+cCkhMs/6vn9DjYrLjNdyy1VsA/M/2vVDMbKeriW7HQnl3cpOjBWjB35I6mwfIm
jQi4WgDn/zzrHjYSHQOlExnV/UTh3kpo01JQ/Y9PI+rUsBT4OZsl4lpOd3G9boqjgID3w
//iLD/EgprCfJyTGaZPW3yd611IWzBRnvJUmhMbszVpDAaSdvruAjsIDTe6c31MTL4N1m
4cAMfHPMmO/1FCuf+zWTPc/t9jeP/z5TB1p6iHCEp8E9403gWXTBAcX529xym232vTg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796244384;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=vteNCrODtiRarIm+hZRyIMx3MXWASaRm6d2ZRrBLQuE=;
b=yl56AFhHDqYlfnA4i1rOiqXE5yp2jnzpPxTfqPhlzugRST5rb3VW3IGc5m5lxvqYe6dh
bIxHJqjUyGBOOyqVBtobpRJRfTktZkQOgeFrapmvuUIRbzaTCDgF3mDHq6iRYQoRwACWW
R7xBnD1eQI9/iMmq6bOIvxgOu5g9nSKcXeZXs4ENdXT5xqvdwqgVjl0koue/gnxyPCUu9
sJ20Mdjw5kMO/eVLnbZVCZCSr2pQqjnpgmD+ULT7i3/iBzlWGNrzVLlEJjUWOf+V+CyBj
FSelu+zVpK3w2D+FffWmWGOK1MXgQJg2kliu2+KkjgUkxcGqgdX13txaVGTA3o4QAZw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zMW++C8x;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 792E8606A336;
Wed, 2 Dec 2026 20:46:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zMW++C8x
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796244383;
b=LFp18VhVsDvZQ9NKv3MwXtE6XvJtCbF8qXsP5IHttXMf4riFbmJ9PMsvriEcD10IJ/ex
0oin8kthDDYwyBzCNOK76Qo1/PPgYMMIYFinAbEr2TRA0fAhsQ4cX++yQycsFqQdl+pHx
GM8pkFg+8wfF/Wec9y/wug02DmUxYbERW1V/ybzx9L2BClp8KhHrGVr4pPKwc9F4i1Odh
i+qqEu52NaQT7AFgpMgmV/GOMVTV6GXcuNkidCCauH2ORXtT1azZn3dYptg1+WMmVX+qK
MZyXhAgdy7RIpdNloVuV287qtnVvLtnL1fhhYaa36ntyKj0U3ZOBBDGZjoxJljrAF2Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796244383;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=vteNCrODtiRarIm+hZRyIMx3MXWASaRm6d2ZRrBLQuE=;
b=D/kL34nNg8mD42YBoqLQINlTiPOEQBJBR/I5Pkgw+uU+VtiOZ6rZE+yfMpvccn5QU84z
0r2wkVVrBFSYh+DR07nj6AFxs+Jsdcj7hnX80ewjQAsfMUMLKulmnlJuTO1QXlafaaugW
qPUvEVy8Eok7bAwRtodBR6iXRUTDsZEr1F7THrBdXKUZ7apr3fm3GipVnFcFjkh54C/Ew
0zUMQ3bZtkta5S4bXxi7gCsALkNr/+vZH/jdkY/J6m1wIRTDrfT0GE9G/j0AYXubmMyyM
ERdYMttfCumVvjJAjJOJnK6Na7f5OxqU+vftyQsS8f4GjnNDIP9K5ivmNsoarkZ+YQQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=zMW++C8x;
arc=none smtp.remote-ip=74.125.82.179
X-Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44333606A322
for <git@vger.kernel.org>; Wed, 2 Dec 2026 20:46:23 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 44333606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-386ab9ab619so20586492eec.1
for <git@vger.kernel.org>; Wed, 02 Dec 2026 12:46:23 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796244382; x=1796849182; darn=vger.kernel.org;
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:content-type;
bh=vteNCrODtiRarIm+hZRyIMx3MXWASaRm6d2ZRrBLQuE=;
b=zMW++C8xLNfAzAEKed69DAB8aHEOqSFCGp+xkV7EinswVhfi4PqafcuiJ7Szli27O4
4GunOtJmcInK+VzgeVyUHKzYFwHuASMQwdnKbx4a45HbEIrdKnv/8Vj9u2HiMFhorAEM
rCjVUmpZPBkaZ8OVnB8P2NOMHUeW2GNSMFXuVdVSCZfcYPiSOcKpD0Q5oJdFpZHn/M6a
rCHNq92emwQ2BRLBGZM+K48xhByQ1fO8bezA1aFFtFGbJE86AskgD307wuzPxzNUjXOo
vmxGSqG0/Pgcv6++ddtkIlzJi80aGPUSESKmgI6j9lyRCmimVATCZ1mNUIZUF1MPQ2ee
RtPg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796244382; x=1796849182;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=vteNCrODtiRarIm+hZRyIMx3MXWASaRm6d2ZRrBLQuE=;
b=fqPYvTZb2ny0ynyVg2F6xQ/fI/7wFk0aUIy25MTEEM5t9bkGfdSAj6EBAIeMh/8LoF
xhA3pIRnz7j9BqaSdtQ/E7JxEJrTwVOg+xiyHAJuBlQgJauHlUvGpkmCiPm5lIx9nG3P
kFNsLicTFIGwX2yHhCvQRdJg8FFFmkPHgbZZKokxGgbjxkyXMdzg5cGmPI1h13644FWW
rj4pET/3yx8Db+7qkAp8iBzpLCg/euD35/MEhSl5Y132rq3SZKyxJcAdC/krZBlq+Xxn
5AOz2cUPoWexcS7zTynTgsYtGAEa+enntCgTYTRt199h07EEJe3BAuftxWbfWXbilmBg
8WvA==
X-Gm-Message-State: APuU4Z+tMk7gZ0jVGh05IHTvjys6L0Q6WOZRGkx7kA8cppToL7I/2oAn
/OgmlZSNbmEcMwC8srWw0JYexhYxaVqsFeFoz2SGly5SE4uyNBoimuAU2uChlmpJ
X-Gm-Gg: AZFdTZf5BvJvdMUlQaz8SL0TU94TUIrONaFjg1vNLRg2oiGerAxKeBthTQWTPpn9jas
O3Kn12WGJp3Ot0mOWNZpnBYDZNHpMVQAS7hC9ARvqbgh4voGLGEPQjmR/R14Foq0oPqNq1qqTtD
NY4QQNGuTZBFpjDrChHv7YsWW+WBw1v9pDfe/CItMviHl+mQYStyFR0zg9apyLGHzeBI5AxLy/9
YrZ6fXZYPJih5vAfiDKHi7WJaFYSM8ZBJTCvtfdgvD52hRoakGnsiceouzevNbl5Wn0nhUa6zzy
hjdB9vKmq2/AXfLGYhHU9M1pMzegxLEiqxdddabFQlT7Djcl0yL8eO/7dWJuNYnJQj3qOm0UQyQ
s2nUqJxpPWQxmv0WPOruSMKtVa4IqFokWmAKApkI82sLtNx8QXnF4we2emWA6SA7l8ZSee7bROd
eVT43rFmlNO1l1iZryAUeHExgzUFiO7b0Q4yewzXFlZarjtUdHr/6JY2zamBfAw+hRMpJ3znf4O
n7iTOIy65KxeK9hGy1jVTTnHfpe9eRm+Wh1IOKaS35/zVsOUlhVsja68gVYXDZxkUeS+w/zvguT
dhJuSOxb0q2+JC4TxSl37divvKjFqTLf6OU06cavgxiTpG/C3k6Ehpey8mwYZkAymhqOesno2HQ
+Vzd8uCHMS9zC9GH2
X-Received: by 2002:a05:7301:7e07:b0:35f:2858:aa4b with SMTP id 5a478bee46e88-38570e23830mr39570765eec.30.1796244382056;
Wed, 02 Dec 2026 12:46:22 -0800 (PST)
X-Received: from localhost.localdomain ([223.190.80.135])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386f6651e2asm47188152eec.27.2026.12.02.12.46.20
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 02 Dec 2026 12:46:21 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
Derrick Stolee <stolee@gmail.com>,
Patrick Steinhardt <ps@pks.im>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261202204608.97770-1-aniketgupta3001@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list