From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 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== 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== 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 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 ; Wed, 2 Dec 2026 20:46:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 44333606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-386ab9ab619so20586492eec.1 for ; Wed, 02 Dec 2026 12:46:23 -0800 (PST) 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) 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) From: Aniket Gupta To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Patrick Steinhardt Subject: [PATCH v6 3/3] bundle-uri: do not die on unresolvable relative URIs Date: Thu, 3 Dec 2026 02:16:08 +0530 Message-ID: <20261202204608.97770-4-aniketgupta3001@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202204608.97770-1-aniketgupta3001@gmail.com> References: <20261105152842.566318-1-aniketgupta3001@gmail.com> <20261126115803.30015-1-aniketgupta3001@gmail.com> <20261202204608.97770-1-aniketgupta3001@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 = /bundle.bdl [bundle "two"] uri = bundle.bdl - [bundle "three"] - 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 '\'''\'' + 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)