Re: [PATCH v3 3/3] bundle-uri: do not die on unresolvable relative URIs
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 6, 2026, 14:51 UTC
- Message-ID
- <0ad84940-b107-4015-849b-f91f1e4ac1d3@gmail.com>
- In-Reply-To
- <20261105152842.566318-4-aniketgupta3001@gmail.com>
On 11/5/2026 10:28 AM, Aniket Gupta wrote:
Show 11 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 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.
This TODO was added in ebc39479558 (bundle-uri: allow relative URLs in bundle lists, 2022-12-22) by _me_, so clearly I thought that this was a good change at the time. I should retract my concerns about the change from patch 1.
The only thing that is different now is that the feature has existed for a while, so maybe some depend on this behavior that we're changing. That's unlikely to be important.
So I'll officially say: thanks for contributing this cleanup!
Show 30 quoted lines
> @@ -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
> EOFIn the context of this diff, this looks like you are removing the bad input, but this is actually the expected output of the test-tool.
The input is a few lines earlier:
cat >in <<-\EOF && bundle.one.uri=bundle.bdl bundle.two.uri=../bundle.bdl bundle.three.uri=../../bundle.bdl EOF
Show 11 quoted lines
> > - # 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 > +
But this err.expect matches.
> 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
And now we're actually seeing the list match the expectation (minus the broken item).
LGTM. Thanks, -Stolee