git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/3] bundle-uri: do not die on unresolvable relative URIs

From
AGAniket Gupta <aniketgupta3001@gmail.com>
Date
Nov 5, 2026, 15:28 UTC
Message-ID
<20261105152842.566318-4-aniketgupta3001@gmail.com>
In-Reply-To
<20261105152842.566318-1-aniketgupta3001@gmail.com>

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 and leaves the bundle without a URI. The download code already skips such a bundle, so the clone carries on with the others.

This resolves the TODO in t5750, so update the test to match.
Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 bundle-uri.c                | 10 +++++++++-
 t/t5750-bundle-uri-parse.sh | 15 +++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/bundle-uri.c b/bundle-uri.c
index 2bb2eb99e4..1f198ef9a9 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -210,9 +210,17 @@ static int bundle_list_update(const char *key, const char *value,
 	strbuf_release(&id);
 
 	if (!strcmp(subkey, "uri")) {
+		struct strbuf err = STRBUF_INIT;
+
 		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 -1;
+		}
 		return 0;
 	}
 
diff --git a/t/t5750-bundle-uri-parse.sh b/t/t5750-bundle-uri-parse.sh
index 70ae94c4d0..8abf8f31ae 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' '
-- 
2.43.0
Previous: Aniket GuptaNext: Derrick Stolee
Message 8 of 13 in “bundle-uri: do not die on unresolvable relative URIs”
  1. 0/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 5, 2026
  2. 1/3 remote: add relative_url_gently()Aniket Gupta, Nov 5, 2026
  3. Derrick StoleeNov 6, 2026
  4. 2/3 remote: do not show credentials when relative_url() failsAniket Gupta, Nov 5, 2026
  5. Derrick StoleeNov 6, 2026
  6. Junio C HamanoNov 6, 2026
  7. Aniket GuptaNov 9, 2026
  8. 3/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 5, 2026
  9. Derrick StoleeNov 6, 2026
  10. Derrick StoleeNov 6, 2026
  11. Aniket GuptaNov 6, 2026
  12. Patrick SteinhardtNov 9, 2026
  13. Aniket GuptaNov 9, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.