Re: [PATCH v5 3/3] bundle-uri: do not die on unresolvable relative URIs
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 1, 2026, 12:35 UTC
- Message-ID
- <aw6--STmep1UZ3qy@pks.im>
- In-Reply-To
- <20261126115803.30015-4-aniketgupta3001@gmail.com>
On Thu, Nov 26, 2026 at 05:28:03PM +0530, Aniket Gupta wrote:
Show 52 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, 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.
>
> 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 | 13 ++++++++++++-
> t/t5558-clone-bundle-uri.sh | 16 ++++++++++++++++
> t/t5750-bundle-uri-parse.sh | 15 +++++++--------
> 3 files changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/bundle-uri.c b/bundle-uri.c
> index 41c817eefb..3b54622532 100644
> --- a/bundle-uri.c
> +++ b/bundle-uri.c
> @@ -214,11 +214,22 @@ static int bundle_list_update(const char *key, const char *value,
> strbuf_release(&id);
>
> if (!strcmp(subkey, "uri")) {
> + struct strbuf err = STRBUF_INIT;
> +
> if (!value)
> return config_error_nonbool(key);
> 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);
> + hashmap_remove(&list->bundles, &bundle->ent, NULL);
> + clear_remote_bundle_info(bundle, NULL);
> + free(bundle);
> + return -1;
> + }
> return 0;
> }This is now weirdly inconsistent. We error out and remove the entry from the map again in the case where we cannot parse the URI, but we don't in case there is no value in the first place? That doesn't make a ton of sense to me.
This change also raises the question why we error on a broken URI, but not on a broken creation token. Maybe the creation token isn't needed?
In any case, this could have been avoided if we add the entry to the map at the end of the function, only, after we have parsed everything.
Patrick