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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 23, 2026, 21:04 UTC
Message-ID
<xmqq1p8b5kfw.fsf@gitster.g>
In-Reply-To
<ce37d9588d833d306df3cc9d0e656e09c32e6b44.1795415793.git.aniketgupta3001@gmail.com>
Aniket Gupta <aniketgupta3001@gmail.com> writes:
Show 14 quoted lines
> 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 stops
> parsing the list, leaving the bundle without a URI.
>
> 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 tells us the story much better than the previous rounds.
Show 30 quoted lines
> 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 9797eaed9a..d2a33b930f 100644
> --- a/bundle-uri.c
> +++ b/bundle-uri.c
> @@ -209,9 +209,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;
>  	}

This is minor, but because bundle_list_update() places the bundle in the '.bundles' hashmap of 'list' before we come here, a failing entry will stay in the hashmap with '.uri' of 'bundle' set to NULL. If valid bundles precede a bad entry, fetch_bundle_uri_internal() may emit a "error: bundle '<id>' has no uri" while iterating over '.bundles' of 'list' before the clone proceeds with the remote fetch, which may or may not be what we want. After all, we have already issued an error message, so...?

Thanks.
Previous: Aniket GuptaNext: Aniket Gupta
Message 18 of 37 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
  14. 0/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 23, 2026
  15. 1/3 remote: add relative_url_gently()Aniket Gupta, Nov 23, 2026
  16. 2/3 remote: name the original URL when relative_url() failsAniket Gupta, Nov 23, 2026
  17. 3/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 23, 2026
  18. Junio C HamanoNov 23, 2026
  19. Aniket GuptaNov 23, 2026
  20. Derrick StoleeNov 23, 2026
  21. 0/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 26, 2026
  22. 1/3 remote: add relative_url_gently()Aniket Gupta, Nov 26, 2026
  23. 2/3 remote: name the original URL when relative_url() failsAniket Gupta, Nov 26, 2026
  24. Patrick SteinhardtDec 1, 2026
  25. Aniket GuptaDec 1, 2026
  26. 3/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Nov 26, 2026
  27. Derrick StoleeNov 30, 2026
  28. Patrick SteinhardtDec 1, 2026
  29. Aniket GuptaDec 1, 2026
  30. Patrick SteinhardtDec 2, 2026
  31. Patrick SteinhardtDec 1, 2026
  32. Aniket GuptaDec 1, 2026
  33. 0/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Dec 2, 2026
  34. 1/3 remote: add relative_url_gently()Aniket Gupta, Dec 2, 2026
  35. 2/3 remote: name the original URL when relative_url() failsAniket Gupta, Dec 2, 2026
  36. 3/3 bundle-uri: do not die on unresolvable relative URIsAniket Gupta, Dec 2, 2026
  37. Patrick SteinhardtDec 3, 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.