🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
26 messages
26 total messages Started by Aniket Gupta Thu, 05 Nov 2026 15:28
[PATCH v3 0/3] bundle-uri: do not die on unresolvable relative URIs
#2421
Author: Aniket Gupta
Date: Thu, 05 Nov 2026 15:28
29 lines
11397 bytes
A bundle list can contain a relative URI that cannot be resolved, and
today one such entry makes the whole clone die. This series lets the
bundle code report it and skip that bundle instead.

Changes since v2:
- split into three patches
- reworded the commit message to describe relative_url() as a thin
  wrapper around relative_url_gently()
- the credentials test now compares the full error message
- the error names the URL that was passed in, not what is left of it
  after some components were stripped off

Aniket Gupta (3):
  remote: add relative_url_gently()
  remote: do not show credentials when relative_url() fails
  bundle-uri: do not die on unresolvable relative URIs

 bundle-uri.c                | 10 +++++++++-
 remote.c                    | 37 +++++++++++++++++++++++++++++++------
 remote.h                    |  8 ++++++++
 t/t0060-path-utils.sh       |  9 +++++++++
 t/t5750-bundle-uri-parse.sh | 15 +++++++--------
 5 files changed, 64 insertions(+), 15 deletions(-)


base-commit: ebdc087dc99d68bb340c282b2ba5f722def28d19
-- 
2.43.0
[PATCH v3 1/3] remote: add relative_url_gently()
#2427
Author: Aniket Gupta
Date: Thu, 05 Nov 2026 15:28
109 lines
13843 bytes
relative_url() calls die() when there are more "../" components in the
URL than the base URL can absorb. A caller that would rather carry on
has no way to do so.

Add relative_url_gently(), which returns NULL and adds the reason to a
strbuf instead of dying. relative_url() is now a thin wrapper around
it that continues to die, so existing callers behave the same.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c | 34 ++++++++++++++++++++++++++++------
 remote.h |  8 ++++++++
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/remote.c b/remote.c
index 49ee2ea318..899d805b76 100644
--- a/remote.c
+++ b/remote.c
@@ -3005,7 +3005,8 @@ void remote_state_clear(struct remote_state *remote_state)
 }
 
 /*
- * Returns 1 if it was the last chop before ':'.
+ * Returns 1 if it was the last chop before ':', or -1 if there is
+ * nothing left to chop.
  */
 static int chop_last_dir(char **remoteurl, int is_relative)
 {
@@ -3022,16 +3023,15 @@ static int chop_last_dir(char **remoteurl, int is_relative)
 	}
 
 	if (is_relative || !strcmp(".", *remoteurl))
-		die(_("cannot strip one component off url '%s'"),
-			*remoteurl);
+		return -1;
 
 	free(*remoteurl);
 	*remoteurl = xstrdup(".");
 	return 0;
 }
 
-char *relative_url(const char *remote_url, const char *url,
-		   const char *up_path)
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err)
 {
 	int is_relative = 0;
 	int colonsep = 0;
@@ -3073,8 +3073,19 @@ char *relative_url(const char *remote_url, const char *url,
 	 */
 	while (*url) {
 		if (starts_with_dot_dot_slash_native(url)) {
+			int chopped;
+
 			url += 3;
-			colonsep |= chop_last_dir(&remoteurl, is_relative);
+			chopped = chop_last_dir(&remoteurl, is_relative);
+			if (chopped < 0) {
+				strbuf_addf(err,
+					    _("cannot strip one component off url '%s'"),
+					    remoteurl);
+				free(remoteurl);
+				strbuf_release(&sb);
+				return NULL;
+			}
+			colonsep |= chopped;
 		} else if (starts_with_dot_slash_native(url))
 			url += 2;
 		else
@@ -3102,6 +3113,17 @@ char *relative_url(const char *remote_url, const char *url,
 	return strbuf_detach(&sb, NULL);
 }
 
+char *relative_url(const char *remote_url, const char *url,
+		   const char *up_path)
+{
+	struct strbuf err = STRBUF_INIT;
+	char *out = relative_url_gently(remote_url, url, up_path, &err);
+
+	if (!out)
+		die("%s", err.buf);
+	return out;
+}
+
 int valid_remote_name(const char *name)
 {
 	int result;
diff --git a/remote.h b/remote.h
index cca02033b9..940474fa71 100644
--- a/remote.h
+++ b/remote.h
@@ -478,6 +478,14 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
 		   const char *up_path);
 
+/*
+ * Like relative_url(), but if `url` cannot be resolved against
+ * `remote_url`, return NULL and add the reason to `err` instead of
+ * dying. `err` must not be NULL.
+ */
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err);
+
 int valid_remote_name(const char *name);
 
 #endif
-- 
2.43.0
[PATCH v3 2/3] remote: do not show credentials when relative_url() fails
#2425
Author: Aniket Gupta
Date: Thu, 05 Nov 2026 15:28
56 lines
12805 bytes
When relative_url() cannot resolve a URL, it names the URL in its error
message. If the URL contains a user name and password, both end up in
the message, and from there in terminal output and logs.

Pass the URL through transport_anonymize_url() first. Also name the
URL that was passed in rather than what is left of it after some
components have already been stripped off, which is what a user would
recognize.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c              | 5 ++++-
 t/t0060-path-utils.sh | 9 +++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index 899d805b76..36834b129c 100644
--- a/remote.c
+++ b/remote.c
@@ -3078,9 +3078,12 @@ char *relative_url_gently(const char *remote_url, const char *url,
 			url += 3;
 			chopped = chop_last_dir(&remoteurl, is_relative);
 			if (chopped < 0) {
+				char *anon = transport_anonymize_url(remote_url);
+
 				strbuf_addf(err,
 					    _("cannot strip one component off url '%s'"),
-					    remoteurl);
+					    anon);
+				free(anon);
 				free(remoteurl);
 				strbuf_release(&sb);
 				return NULL;
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 56faf5fe73..cea0d13429 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -394,6 +394,15 @@ test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
 test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
 
+test_expect_success 'relative_url() does not show credentials when it fails' '
+	cat >expect <<-\EOF &&
+	fatal: cannot strip one component off url '\''https://host.example/a'\''
+	EOF
+	test_must_fail test-tool submodule resolve-relative-url "" \
+		"https://user:secret@host.example/a" ../../../../../../x 2>actual &&
+	test_cmp expect actual
+'
+
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
-- 
2.43.0
[PATCH v3 3/3] bundle-uri: do not die on unresolvable relative URIs
#2423
Author: Aniket Gupta
Date: Thu, 05 Nov 2026 15:28
73 lines
13184 bytes
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
Re: [PATCH v3 1/3] remote: add relative_url_gently()
#2514
Author: Derrick Stolee
Date: Fri, 06 Nov 2026 14:36
22 lines
12013 bytes
On 11/5/2026 10:28 AM, Aniket Gupta wrote:
> relative_url() calls die() when there are more "../" components in the
> URL than the base URL can absorb. A caller that would rather carry on
> has no way to do so.

I agree that we should have a mechanism to allow users to know about a
broken bundle URI and to respond somehow. 
> Add relative_url_gently(), which returns NULL and adds the reason to a
> strbuf instead of dying. relative_url() is now a thin wrapper around
> it that continues to die, so existing callers behave the same.

This method is good to have, in general, and is written well.

The only question here is if we should be changing the behavior for
bundle-URI clones from halting on bad data to skipping bundles and
doing the full operation from the remote.

(But there's more about this in patch 3, so I'll defer until then.)

Thanks,
-Stolee
Re: [PATCH v3 2/3] remote: do not show credentials when relative_url() fails
#2513
Author: Derrick Stolee
Date: Fri, 06 Nov 2026 14:43
55 lines
13400 bytes
On 11/5/2026 10:28 AM, Aniket Gupta wrote:
> When relative_url() cannot resolve a URL, it names the URL in its error
> message. If the URL contains a user name and password, both end up in
> the message, and from there in terminal output and logs.
> 
> Pass the URL through transport_anonymize_url() first. Also name the
> URL that was passed in rather than what is left of it after some
> components have already been stripped off, which is what a user would
> recognize.

I'm less convinced on this factor. I understand anonymizing the URL if
we are sending it to a location that is perhaps "less trusted" (like
trace logs) but the user asked us to operate on a given URL that caused
problems, so they should know the string that caused problems.

In environments that store stdout/stderr logs, those systems already
need to be careful about such strings in the commands themselves, let
alone the output strings.

And back to the bundle-URI application: if the bundle list uses such
URIs for its child bundles, then that's not a safe mechanism for
communicating those credentials. This isn't going to protect secrets
like that from being exposed.

This is just my opinion on the necessity of this change. If we _do_
want this change, then I continued my review: the patch accomplishes
its goal.
> @@ -3078,9 +3078,12 @@ char *relative_url_gently(const char *remote_url, const char *url,
>  			url += 3;
>  			chopped = chop_last_dir(&remoteurl, is_relative);
>  			if (chopped < 0) {
> +				char *anon = transport_anonymize_url(remote_url);
> +
>  				strbuf_addf(err,
>  					    _("cannot strip one component off url '%s'"),
> -					    remoteurl);
> +					    anon);
> +				free(anon);
>  				free(remoteurl);

This code looks good, assuming taht we want to make this change.

> +test_expect_success 'relative_url() does not show credentials when it fails' '
> +	cat >expect <<-\EOF &&
> +	fatal: cannot strip one component off url '\''https://host.example/a'\''
> +	EOF
> +	test_must_fail test-tool submodule resolve-relative-url "" \
> +		"https://user:secret@host.example/a" ../../../../../../x 2>actual &&
> +	test_cmp expect actual
> +'
Thank you for including a test that demonstrates this change.

Thanks,
-Stolee
Re: [PATCH v3 3/3] bundle-uri: do not die on unresolvable relative URIs
#2511
Author: Derrick Stolee
Date: Fri, 06 Nov 2026 14:51
92 lines
14360 bytes
On 11/5/2026 10:28 AM, Aniket Gupta wrote:
> 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!

> @@ -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

In 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

>  
> -	# 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
Re: [PATCH v3 0/3] bundle-uri: do not die on unresolvable relative URIs
#2515
Author: Derrick Stolee
Date: Fri, 06 Nov 2026 14:57
25 lines
12052 bytes
On 11/5/2026 10:28 AM, Aniket Gupta wrote:
> A bundle list can contain a relative URI that cannot be resolved, and
> today one such entry makes the whole clone die. This series lets the
> bundle code report it and skip that bundle instead.

When reading patch-by-patch, I initially was concerned about the
behavior change. However, patch 3 removes a long-standing TODO
comment _that I wrote_ so I'm inclined to take the change. I
didn't see anything critical to change about these patches.

That said, we may have something for #leftoverbits:

How could we create a toggle to re-enable the die() if desired?

Perhaps a user _wants_ to fail on bad URIs instead of spending
time on an incomplete bundle advertisement and expensive fetch
from the remote.

Such an option could be a follow-up, now that you've implemented
the _gently() version and the bundle URI machinery could decide
for itself whether this is a hard failure or not.

Thanks,
-Stolee
Re: [PATCH v3 0/3] bundle-uri: do not die on unresolvable relative URIs
#2526
Author: Aniket Gupta
Date: Fri, 06 Nov 2026 17:25
21 lines
11374 bytes
Hi Stolee,

Thanks for the review.

> I'm less convinced on this factor.

Fair point. I tried it with a password in the remote URL but the "failed
to download bundle from URI" warning prints it as is. I think this patch
will only cover this one message. The reason I did it is that git
already hides the password when it shows a remote URL. For eg. in the
"From" line of fetch. It is a separate patch so it is easy to drop if
you and Patrick think it is not worth it.

While checking this I noticed that my commit message for patch 3 is not
accurate. It says that the clone carries on with the other bundles, but
the list is only used up to the bad entry (not at all for a list given
to --bundle-uri) and then the clone fetches from the remote. I can send
a v4 with that fixed if its fine

Aniket
Re: [PATCH v3 2/3] remote: do not show credentials when relative_url() fails
#2536
Author: Junio C Hamano
Date: Fri, 06 Nov 2026 19:15
32 lines
13860 bytes
Derrick Stolee <stolee@gmail.com> writes:

> In environments that store stdout/stderr logs, those systems already
> need to be careful about such strings in the commands themselves, let
> alone the output strings.

Hmph, is this true?  How can these systems be _careful_ without
knowing what these strings are?  By guessing that https:// is a common
enough thing that shoud raise red flag if there is some:thing@ that
follows it?

> And back to the bundle-URI application: if the bundle list uses such
> URIs for its child bundles, then that's not a safe mechanism for
> communicating those credentials. This isn't going to protect secrets
> like that from being exposed.

This is very true.  So the patch may be protecting us against an
issue that does not exist in practice?

Where do we use anonymize_url() in existing code paths?

 - "git clone" leaving "clone: from X" in the reflog
 - "git fetch" showing "From X" to show ref updates
 - "git push" shwoing "Pushing to X" in verbose output
 - remote-curl talking about "url" in die() messages
 - transport showing "To X" to show push_report.

These are all talking about what is shown on the screen except for
the reflog entry left by "git clone", I think.

Thanks.
Re: [PATCH v3 2/3] remote: do not show credentials when relative_url() fails
#2696
Author: Aniket Gupta
Date: Mon, 09 Nov 2026 10:39
14 lines
11481 bytes
> I'm less convinced on this factor. I understand anonymizing the URL if
> we are sending it to a location that is perhaps "less trusted" (like
> trace logs) but the user asked us to operate on a given URL that caused
> problems, so they should know the string that caused problems.

I answered this on the cover letter by mistake. Here it is again. Apologies for the spam.

Fair point. I tried it with a password in the remote URL but the "failed
to download bundle from URI" warning prints it as is. I think this patch
will only cover this one message. The reason I did it is that git
already hides the password when it shows a remote URL. For eg. in the
"From" line of fetch. It is a separate patch so it is easy to drop if
you and Patrick think it is not worth it.
[PATCH v4 0/3] bundle-uri: do not die on unresolvable relative URIs
#3604
Author: Aniket Gupta
Date: Mon, 23 Nov 2026 06:44
44 lines
12388 bytes
A bundle list can contain a relative URI that cannot be resolved and
one such entry can result in the entire clone dying. This series lets
the bundle code report it and the clone carry on.

Changes since v3:

 * Patch 2: dropped the part that hides credentials as Stolee was not
   convinced it is needed. The part that names the URL that was passed
   in stays, as Patrick wanted. The patch has a new title and its test
   no longer uses a password.

 * Patch 3: fixed the commit message. Previously it said that the
   clone carries on with the other bundles. That is true only for a
   list that a server advertises only for the bundles before the bad
   entry. A list given to --bundle-uri is rejected as a whole. In both
   cases, the clone fetches the rest from the remote. No code change.

 * Rebased onto current master, no conflicts.

Stolee's idea of having a toggle to bring back the die() is not part
of this series. Happy to take that as a follow-up :)

This conflicts a bit with tb/config-null-values in next, which adds a
"!value" check in bundle_list_update() right above the line that patch
3 changes. Keeping both is enough, "!value" check first. I tested that
merge (t0060, t5558, t5750).

Aniket Gupta (3):
  remote: add relative_url_gently()
  remote: name the original URL when relative_url() fails
  bundle-uri: do not die on unresolvable relative URIs

 bundle-uri.c                | 10 +++++++++-
 remote.c                    | 34 ++++++++++++++++++++++++++++------
 remote.h                    |  8 ++++++++
 t/t0060-path-utils.sh       |  9 +++++++++
 t/t5750-bundle-uri-parse.sh | 15 +++++++--------
 5 files changed, 61 insertions(+), 15 deletions(-)


base-commit: f7de81456940dd6f3274e461149bba12965de609
-- 
2.54.0 (Apple Git-157)
[PATCH v4 1/3] remote: add relative_url_gently()
#3606
Author: Aniket Gupta
Date: Mon, 23 Nov 2026 06:44
109 lines
13940 bytes
relative_url() calls die() when there are more "../" components in the
URL than the base URL can absorb. A caller that would rather carry on
has no way to do so.

Add relative_url_gently(), which returns NULL and adds the reason to a
strbuf instead of dying. relative_url() is now a thin wrapper around
it that continues to die, so existing callers behave the same.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c | 34 ++++++++++++++++++++++++++++------
 remote.h |  8 ++++++++
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/remote.c b/remote.c
index df069e802f..be561d633e 100644
--- a/remote.c
+++ b/remote.c
@@ -3101,7 +3101,8 @@ void remote_state_clear(struct remote_state *remote_state)
 }
 
 /*
- * Returns 1 if it was the last chop before ':'.
+ * Returns 1 if it was the last chop before ':', or -1 if there is
+ * nothing left to chop.
  */
 static int chop_last_dir(char **remoteurl, int is_relative)
 {
@@ -3118,16 +3119,15 @@ static int chop_last_dir(char **remoteurl, int is_relative)
 	}
 
 	if (is_relative || !strcmp(".", *remoteurl))
-		die(_("cannot strip one component off url '%s'"),
-			*remoteurl);
+		return -1;
 
 	free(*remoteurl);
 	*remoteurl = xstrdup(".");
 	return 0;
 }
 
-char *relative_url(const char *remote_url, const char *url,
-		   const char *up_path)
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err)
 {
 	int is_relative = 0;
 	int colonsep = 0;
@@ -3169,8 +3169,19 @@ char *relative_url(const char *remote_url, const char *url,
 	 */
 	while (*url) {
 		if (starts_with_dot_dot_slash_native(url)) {
+			int chopped;
+
 			url += 3;
-			colonsep |= chop_last_dir(&remoteurl, is_relative);
+			chopped = chop_last_dir(&remoteurl, is_relative);
+			if (chopped < 0) {
+				strbuf_addf(err,
+					    _("cannot strip one component off url '%s'"),
+					    remoteurl);
+				free(remoteurl);
+				strbuf_release(&sb);
+				return NULL;
+			}
+			colonsep |= chopped;
 		} else if (starts_with_dot_slash_native(url))
 			url += 2;
 		else
@@ -3198,6 +3209,17 @@ char *relative_url(const char *remote_url, const char *url,
 	return strbuf_detach(&sb, NULL);
 }
 
+char *relative_url(const char *remote_url, const char *url,
+		   const char *up_path)
+{
+	struct strbuf err = STRBUF_INIT;
+	char *out = relative_url_gently(remote_url, url, up_path, &err);
+
+	if (!out)
+		die("%s", err.buf);
+	return out;
+}
+
 int valid_remote_name(const char *name)
 {
 	int result;
diff --git a/remote.h b/remote.h
index cca02033b9..940474fa71 100644
--- a/remote.h
+++ b/remote.h
@@ -478,6 +478,14 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
 		   const char *up_path);
 
+/*
+ * Like relative_url(), but if `url` cannot be resolved against
+ * `remote_url`, return NULL and add the reason to `err` instead of
+ * dying. `err` must not be NULL.
+ */
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err);
+
 int valid_remote_name(const char *name);
 
 #endif
-- 
2.54.0 (Apple Git-157)
[PATCH v4 2/3] remote: name the original URL when relative_url() fails
#3605
Author: Aniket Gupta
Date: Mon, 23 Nov 2026 06:44
53 lines
12719 bytes
When relative_url() cannot resolve a URL, its error message does not
name the URL it was given but what is left of it after some "../"
components have already been stripped off. With a base URL of "./a/b"
and too many "../", it says:

    cannot strip one component off url '.'

which does not help a user to tell what is wrong with the URL.

Name the URL that was passed in instead.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c              | 2 +-
 t/t0060-path-utils.sh | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index be561d633e..ee10c7a003 100644
--- a/remote.c
+++ b/remote.c
@@ -3176,7 +3176,7 @@ char *relative_url_gently(const char *remote_url, const char *url,
 			if (chopped < 0) {
 				strbuf_addf(err,
 					    _("cannot strip one component off url '%s'"),
-					    remoteurl);
+					    remote_url);
 				free(remoteurl);
 				strbuf_release(&sb);
 				return NULL;
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 56faf5fe73..0d16b2c884 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -394,6 +394,15 @@ test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
 test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
 
+test_expect_success 'relative_url() names the URL it was given when it fails' '
+	cat >expect <<-\EOF &&
+	fatal: cannot strip one component off url '\''https://host.example/a'\''
+	EOF
+	test_must_fail test-tool submodule resolve-relative-url "" \
+		"https://host.example/a" ../../../../../../x 2>actual &&
+	test_cmp expect actual
+'
+
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
-- 
2.54.0 (Apple Git-157)
[PATCH v4 3/3] bundle-uri: do not die on unresolvable relative URIs
#3607
Author: Aniket Gupta
Date: Mon, 23 Nov 2026 06:44
78 lines
13558 bytes
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 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;
 	}
 
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.54.0 (Apple Git-157)
Re: [PATCH v4 0/3] bundle-uri: do not die on unresolvable relative URIs
#3623
Author: Derrick Stolee
Date: Mon, 23 Nov 2026 14:54
30 lines
12249 bytes
On 11/23/2026 1:44 AM, Aniket Gupta wrote:
> A bundle list can contain a relative URI that cannot be resolved and
> one such entry can result in the entire clone dying. This series lets
> the bundle code report it and the clone carry on.
> 
> Changes since v3:
> 
>  * Patch 2: dropped the part that hides credentials as Stolee was not
>    convinced it is needed. The part that names the URL that was passed
>    in stays, as Patrick wanted. The patch has a new title and its test
>    no longer uses a password.
> 
>  * Patch 3: fixed the commit message. Previously it said that the
>    clone carries on with the other bundles. That is true only for a
>    list that a server advertises only for the bundles before the bad
>    entry. A list given to --bundle-uri is rejected as a whole. In both
>    cases, the clone fetches the rest from the remote. No code change.
> 
>  * Rebased onto current master, no conflicts.

Thanks. This version LGTM.

> Stolee's idea of having a toggle to bring back the die() is not part
> of this series. Happy to take that as a follow-up :)

I agree it doesn't need to be added here.

Thanks,
-Stolee
Re: [PATCH v4 3/3] bundle-uri: do not die on unresolvable relative URIs
#3662
Author: Junio C Hamano
Date: Mon, 23 Nov 2026 21:04
61 lines
15043 bytes
Aniket Gupta <aniketgupta3001@gmail.com> writes:

> 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.

> 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.
Re: [PATCH v4 3/3] bundle-uri: do not die on unresolvable relative URIs
#3674
Author: Aniket Gupta
Date: Mon, 23 Nov 2026 22:25
20 lines
11738 bytes
> 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.

You are right. I am able to repro it with a server that advertises a bad
entry: after the three errors we already print there is a fourth one,
"error: bundle '<id>' has no uri". A list given to --bundle-uri does not
show it, as that whole list is rejected before we get there.

> which may or may not be what we want.  After all, we have already
> issued an error message, so...?

I dont think we need it since the earlier errors already say what is
wrong. I tried dropping the bundle from the list when its URI cannot be
resolved. The clone behaves the same, just without the extra error, and
the bundle-uri tests still pass. I did not want to hide it in
fetch_bundle_uri_internal(), as a bundle that is advertised without any
uri should still be reported, like we do today. Will do the drop in v5
and add a test for it.
[PATCH v5 0/3] bundle-uri: do not die on unresolvable relative URIs
#3897
Author: Aniket Gupta
Date: Thu, 26 Nov 2026 11:58
40 lines
12212 bytes
A bundle list can contain a relative URI that cannot be resolved and
one such entry can result in the entire clone dying. This series lets
the bundle code report it and the clone carry on.

Changes in v5:

 * Patch 3: drop the bundle from the list when its URI cannot be
   resolved. A list that a server advertises no longer reports that
   bundle a second time as having no uri (Junio). Added a clone test
   for it.

Changes in v4:

 * Patch 2: dropped the part that hides credentials as Stolee was not
   convinced it is needed. The part that names the URL that was passed
   in stays, as Patrick wanted. The patch has a new title and its test
   no longer uses a password.

 * Patch 3: fixed the commit message. Previously it said that the
   clone carries on with the other bundles. That is true only for the
   bundles before the bad entry, in a list that a server advertises. A
   list given to --bundle-uri is rejected as a whole. In both cases,
   the clone fetches the rest from the remote. No code change.

Aniket Gupta (3):
  remote: add relative_url_gently()
  remote: name the original URL when relative_url() fails
  bundle-uri: do not die on unresolvable relative URIs

 bundle-uri.c                | 13 ++++++++++++-
 remote.c                    | 34 ++++++++++++++++++++++++++++------
 remote.h                    |  8 ++++++++
 t/t0060-path-utils.sh       |  9 +++++++++
 t/t5558-clone-bundle-uri.sh | 16 ++++++++++++++++
 t/t5750-bundle-uri-parse.sh | 15 +++++++--------
 6 files changed, 80 insertions(+), 15 deletions(-)

-- 
2.54.0 (Apple Git-157)
[PATCH v5 1/3] remote: add relative_url_gently()
#3898
Author: Aniket Gupta
Date: Thu, 26 Nov 2026 11:58
109 lines
13896 bytes
relative_url() calls die() when there are more "../" components in the
URL than the base URL can absorb. A caller that would rather carry on
has no way to do so.

Add relative_url_gently(), which returns NULL and adds the reason to a
strbuf instead of dying. relative_url() is now a thin wrapper around
it that continues to die, so existing callers behave the same.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c | 34 ++++++++++++++++++++++++++++------
 remote.h |  8 ++++++++
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/remote.c b/remote.c
index 2b7d26b844..3bca10364e 100644
--- a/remote.c
+++ b/remote.c
@@ -3108,7 +3108,8 @@ void remote_state_clear(struct remote_state *remote_state)
 }
 
 /*
- * Returns 1 if it was the last chop before ':'.
+ * Returns 1 if it was the last chop before ':', or -1 if there is
+ * nothing left to chop.
  */
 static int chop_last_dir(char **remoteurl, int is_relative)
 {
@@ -3125,16 +3126,15 @@ static int chop_last_dir(char **remoteurl, int is_relative)
 	}
 
 	if (is_relative || !strcmp(".", *remoteurl))
-		die(_("cannot strip one component off url '%s'"),
-			*remoteurl);
+		return -1;
 
 	free(*remoteurl);
 	*remoteurl = xstrdup(".");
 	return 0;
 }
 
-char *relative_url(const char *remote_url, const char *url,
-		   const char *up_path)
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err)
 {
 	int is_relative = 0;
 	int colonsep = 0;
@@ -3176,8 +3176,19 @@ char *relative_url(const char *remote_url, const char *url,
 	 */
 	while (*url) {
 		if (starts_with_dot_dot_slash_native(url)) {
+			int chopped;
+
 			url += 3;
-			colonsep |= chop_last_dir(&remoteurl, is_relative);
+			chopped = chop_last_dir(&remoteurl, is_relative);
+			if (chopped < 0) {
+				strbuf_addf(err,
+					    _("cannot strip one component off url '%s'"),
+					    remoteurl);
+				free(remoteurl);
+				strbuf_release(&sb);
+				return NULL;
+			}
+			colonsep |= chopped;
 		} else if (starts_with_dot_slash_native(url))
 			url += 2;
 		else
@@ -3205,6 +3216,17 @@ char *relative_url(const char *remote_url, const char *url,
 	return strbuf_detach(&sb, NULL);
 }
 
+char *relative_url(const char *remote_url, const char *url,
+		   const char *up_path)
+{
+	struct strbuf err = STRBUF_INIT;
+	char *out = relative_url_gently(remote_url, url, up_path, &err);
+
+	if (!out)
+		die("%s", err.buf);
+	return out;
+}
+
 int valid_remote_name(const char *name)
 {
 	int result;
diff --git a/remote.h b/remote.h
index cca02033b9..940474fa71 100644
--- a/remote.h
+++ b/remote.h
@@ -478,6 +478,14 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
 		   const char *up_path);
 
+/*
+ * Like relative_url(), but if `url` cannot be resolved against
+ * `remote_url`, return NULL and add the reason to `err` instead of
+ * dying. `err` must not be NULL.
+ */
+char *relative_url_gently(const char *remote_url, const char *url,
+			  const char *up_path, struct strbuf *err);
+
 int valid_remote_name(const char *name);
 
 #endif
-- 
2.54.0 (Apple Git-157)
[PATCH v5 2/3] remote: name the original URL when relative_url() fails
#3899
Author: Aniket Gupta
Date: Thu, 26 Nov 2026 11:58
53 lines
12676 bytes
When relative_url() cannot resolve a URL, its error message does not
name the URL it was given but what is left of it after some "../"
components have already been stripped off. With a base URL of "./a/b"
and too many "../", it says:

    cannot strip one component off url '.'

which does not help a user to tell what is wrong with the URL.

Name the URL that was passed in instead.

Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
---
 remote.c              | 2 +-
 t/t0060-path-utils.sh | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index 3bca10364e..25e607abf2 100644
--- a/remote.c
+++ b/remote.c
@@ -3183,7 +3183,7 @@ char *relative_url_gently(const char *remote_url, const char *url,
 			if (chopped < 0) {
 				strbuf_addf(err,
 					    _("cannot strip one component off url '%s'"),
-					    remoteurl);
+					    remote_url);
 				free(remoteurl);
 				strbuf_release(&sb);
 				return NULL;
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 56faf5fe73..0d16b2c884 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -394,6 +394,15 @@ test_submodule_relative_url "../" "$(pwd)/addtest" "../repo" "$(pwd)/repo"
 test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
 
+test_expect_success 'relative_url() names the URL it was given when it fails' '
+	cat >expect <<-\EOF &&
+	fatal: cannot strip one component off url '\''https://host.example/a'\''
+	EOF
+	test_must_fail test-tool submodule resolve-relative-url "" \
+		"https://host.example/a" ../../../../../../x 2>actual &&
+	test_cmp expect actual
+'
+
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
-- 
2.54.0 (Apple Git-157)
[PATCH v5 3/3] bundle-uri: do not die on unresolvable relative URIs
#3900
Author: Aniket Gupta
Date: Thu, 26 Nov 2026 11:58
112 lines
15226 bytes
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;
 	}
 
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..02b9b38c19 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.54.0 (Apple Git-157)
Re: [PATCH v5 3/3] bundle-uri: do not die on unresolvable relative URIs
#4158
Author: Derrick Stolee
Date: Mon, 30 Nov 2026 19:11
31 lines
12549 bytes
On 11/26/2026 6:58 AM, Aniket Gupta wrote:

> 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
> +'
> +
This is the new test in v5. LGTM.

Thanks,
-Stolee
Re: [PATCH v5 0/3] bundle-uri: do not die on unresolvable relative URIs
#4194
Author: Aniket Gupta
Date: Tue, 01 Dec 2026 14:46
11 lines
11149 bytes
> It would help if you could also include a range-diff between the
> versions so that reviewers know what they need to focus on. Tools like
> b4 help greatly with this, as they manage most of that bookkeeping for
> you.

Thanks for the tip. I installed and tried b4 on this series, but it
seems that it needs to track the earlier versions itself, and v1 to v5
were sent without it. For v6 I am planning to add the range-diff
against v5 using "git format-patch --range-diff". I will use b4 for new
patches and new threads.
Re: [PATCH v5 2/3] remote: name the original URL when relative_url() fails
#4197
Author: Aniket Gupta
Date: Tue, 01 Dec 2026 14:58
7 lines
10942 bytes
> Anyway, that's not a problem you introduced. It might've made sense to
> include another patch on top that renames e.g. `remote_url` to
> `full_remote_url`, but you don't have to.

Yup it is confusing. I can fix it in a follow-up patch after this
series.
Re: [PATCH v5 3/3] bundle-uri: do not die on unresolvable relative URIs
#4203
Author: Aniket Gupta
Date: Tue, 01 Dec 2026 15:43
29 lines
12255 bytes
> This is now weirdly inconsistent. [...]

I had added the removal in v5 because of Junio's v4 review. A bad URI
left an entry without a uri in the map. For a list that a server
advertises, the clone then reported the same bundle a second time, as
having no uri. The check for a missing value didnt come from me
though... it landed upstream while v4 was in review ("bundle-uri: handle
NULL values in bundle lists"). It cannot cause the second error: a line
without a value in the server's advertisement is rejected earlier, and a
list file with one is rejected as a whole. I agree that it reads oddly
that the 2 cases differ. How about I drop the bundle in both in v6?

> 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?

I did not change how the creation token is handled, and a broken one
warns like before. It is needed for the creationToken heuristic and a
bundle with token 0 gets skipped. Making it an error feels like a
separate change... how about we leave it?

> 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.

I tested this. The function only sees one key at a time. If another key
of the same bundle, for eg creationToken, comes first, the entry is
already in the map. Adding it last fixes the case where the bad uri
comes first, but if creationToken comes first the clone still prints
"bundle '<id>' has no uri". It made sense to keep the removal.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads