{"thread":{"id":"66689","subject":"[PATCH] bundle-uri: do not die on unresolvable relative URIs","startedAt":"2026-10-28T11:58:18Z","lastAt":"2026-11-05T15:29:06Z","messageCount":6,"participants":["Aniket Gupta","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556656","messageId":"20261028115818.410-1-aniketgupta3001@gmail.com","threadId":"66689","inReplyTo":null,"subject":"[PATCH] bundle-uri: do not die on unresolvable relative URIs","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-10-28T11:58:18Z","receivedAt":"2026-10-28T11:58:18Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"relative_url() calls die() when the relative URL has more \"../\"\ncomponents than the remote URL can absorb. bundle_list_update() calls\nit on URIs taken from a bundle list and a single bad entry takes down\nthe whole command.\n\nAdd relative_url_gently() which returns NULL and records the reason in\na strbuf instead of dying. This will keep relative_url() as a wrapper\nthat dies so the submodule callers are unchanged. Use the new function\nin bundle_list_update() and report the problem as an error like the\nother malformed lines in a bundle list.\n\nUpdate the test in t5750 accordingly and drop its TODO.\n\nSigned-off-by: Aniket Gupta <aniketgupta3001@gmail.com>\n---\n bundle-uri.c                | 10 +++++++++-\n remote.c                    | 39 +++++++++++++++++++++++++++++--------\n remote.h                    |  8 ++++++++\n t/t5750-bundle-uri-parse.sh | 15 +++++++-------\n 4 files changed, 55 insertions(+), 17 deletions(-)\n\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2bb2eb99e4..1f198ef9a9 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -210,9 +210,17 @@ static int bundle_list_update(const char *key, const char *value,\n \tstrbuf_release(&id);\n \n \tif (!strcmp(subkey, \"uri\")) {\n+\t\tstruct strbuf err = STRBUF_INIT;\n+\n \t\tif (bundle->uri)\n \t\t\treturn -1;\n-\t\tbundle->uri = relative_url(list->baseURI, value, NULL);\n+\t\tbundle->uri = relative_url_gently(list->baseURI, value, NULL,\n+\t\t\t\t\t\t  &err);\n+\t\tif (!bundle->uri) {\n+\t\t\terror(\"%s\", err.buf);\n+\t\t\tstrbuf_release(&err);\n+\t\t\treturn -1;\n+\t\t}\n \t\treturn 0;\n \t}\n \ndiff --git a/remote.c b/remote.c\nindex 49ee2ea318..7472c426aa 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -3005,9 +3005,11 @@ void remote_state_clear(struct remote_state *remote_state)\n }\n \n /*\n- * Returns 1 if it was the last chop before ':'.\n+ * Returns 1 if it was the last chop before ':', or -1 (and records the\n+ * reason in `err`) if there is nothing left to chop.\n  */\n-static int chop_last_dir(char **remoteurl, int is_relative)\n+static int chop_last_dir(char **remoteurl, int is_relative,\n+\t\t\t struct strbuf *err)\n {\n \tchar *rfind = find_last_dir_sep(*remoteurl);\n \tif (rfind) {\n@@ -3021,17 +3023,19 @@ static int chop_last_dir(char **remoteurl, int is_relative)\n \t\treturn 1;\n \t}\n \n-\tif (is_relative || !strcmp(\".\", *remoteurl))\n-\t\tdie(_(\"cannot strip one component off url '%s'\"),\n-\t\t\t*remoteurl);\n+\tif (is_relative || !strcmp(\".\", *remoteurl)) {\n+\t\tstrbuf_addf(err, _(\"cannot strip one component off url '%s'\"),\n+\t\t\t    *remoteurl);\n+\t\treturn -1;\n+\t}\n \n \tfree(*remoteurl);\n \t*remoteurl = xstrdup(\".\");\n \treturn 0;\n }\n \n-char *relative_url(const char *remote_url, const char *url,\n-\t\t   const char *up_path)\n+char *relative_url_gently(const char *remote_url, const char *url,\n+\t\t\t  const char *up_path, struct strbuf *err)\n {\n \tint is_relative = 0;\n \tint colonsep = 0;\n@@ -3073,8 +3077,16 @@ char *relative_url(const char *remote_url, const char *url,\n \t */\n \twhile (*url) {\n \t\tif (starts_with_dot_dot_slash_native(url)) {\n+\t\t\tint chopped;\n+\n \t\t\turl += 3;\n-\t\t\tcolonsep |= chop_last_dir(&remoteurl, is_relative);\n+\t\t\tchopped = chop_last_dir(&remoteurl, is_relative, err);\n+\t\t\tif (chopped < 0) {\n+\t\t\t\tfree(remoteurl);\n+\t\t\t\tstrbuf_release(&sb);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\tcolonsep |= chopped;\n \t\t} else if (starts_with_dot_slash_native(url))\n \t\t\turl += 2;\n \t\telse\n@@ -3102,6 +3114,17 @@ char *relative_url(const char *remote_url, const char *url,\n \treturn strbuf_detach(&sb, NULL);\n }\n \n+char *relative_url(const char *remote_url, const char *url,\n+\t\t   const char *up_path)\n+{\n+\tstruct strbuf err = STRBUF_INIT;\n+\tchar *out = relative_url_gently(remote_url, url, up_path, &err);\n+\n+\tif (!out)\n+\t\tdie(\"%s\", err.buf);\n+\treturn out;\n+}\n+\n int valid_remote_name(const char *name)\n {\n \tint result;\ndiff --git a/remote.h b/remote.h\nindex cca02033b9..940474fa71 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -478,6 +478,14 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);\n char *relative_url(const char *remote_url, const char *url,\n \t\t   const char *up_path);\n \n+/*\n+ * Like relative_url(), but if `url` cannot be resolved against\n+ * `remote_url`, return NULL and add the reason to `err` instead of\n+ * dying. `err` must not be NULL.\n+ */\n+char *relative_url_gently(const char *remote_url, const char *url,\n+\t\t\t  const char *up_path, struct strbuf *err);\n+\n int valid_remote_name(const char *name);\n \n #endif\ndiff --git a/t/t5750-bundle-uri-parse.sh b/t/t5750-bundle-uri-parse.sh\nindex 70ae94c4d0..0f0ac29565 100755\n--- a/t/t5750-bundle-uri-parse.sh\n+++ b/t/t5750-bundle-uri-parse.sh\n@@ -68,17 +68,16 @@ test_expect_success 'bundle_uri_parse_line(): relative URIs and parent paths' '\n \t\turi = <uri>/bundle.bdl\n \t[bundle \"two\"]\n \t\turi = bundle.bdl\n-\t[bundle \"three\"]\n-\t\turi = <uri>/../bundle.bdl\n \tEOF\n \n-\t# TODO: We would prefer if parsing a bundle list would not cause\n-\t# a die() and instead would give a warning and allow the rest of\n-\t# a Git command to continue. This test_must_fail is necessary for\n-\t# now until the interface for relative_url() allows for reporting\n-\t# an error instead of die()ing.\n+\tcat >err.expect <<-\\EOF &&\n+\terror: cannot strip one component off url '\\''.'\\''\n+\terror: bad line: '\\''bundle.three.uri=../../bundle.bdl'\\''\n+\tEOF\n+\n \ttest_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&\n-\ttest_grep \"fatal: cannot strip one component off url\" err\n+\ttest_cmp err.expect err &&\n+\ttest_cmp_config_output expect actual\n '\n \n test_expect_success 'bundle_uri_parse_line() parsing edge cases: empty key or value' '\n\nbase-commit: 37b3475fb530c14109211faca33716a173db61ed\n-- \n2.43.0\n\n\n"},{"id":"557314","messageId":"aunb6OjWKWLyl-mp@pks.im","threadId":"66689","inReplyTo":"20261028115818.410-1-aniketgupta3001@gmail.com","subject":"Re: [PATCH] bundle-uri: do not die on unresolvable relative URIs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-03T13:04:49Z","receivedAt":"2026-11-03T13:04:49Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 11:58:18AM +0000, Aniket Gupta wrote:\n> relative_url() calls die() when the relative URL has more \"../\"\n> components than the remote URL can absorb. bundle_list_update() calls\n> it on URIs taken from a bundle list and a single bad entry takes down\n> the whole command.\n\nWhich command?\n\n> Add relative_url_gently() which returns NULL and records the reason in\n> a strbuf instead of dying. This will keep relative_url() as a wrapper\n\ns/will keep/keeps/. We're in present tense.\n\n> that dies so the submodule callers are unchanged. Use the new function\n> in bundle_list_update() and report the problem as an error like the\n> other malformed lines in a bundle list.\n\nThese \"bundle lists\" are quite abstract here. It would help the reader\nif the commit message briefly mentioned where such a list even comes\nfrom.\n\nEven more importantly though, do we now only print the error and then\ndie or do we continue? And if the latter, why is it fine to continue\neven if we have failed to retrieve the bundle? And is it fine to\ncontinue for both callers of this function?\n\n> diff --git a/bundle-uri.c b/bundle-uri.c\n> index 2bb2eb99e4..1f198ef9a9 100644\n> --- a/bundle-uri.c\n> +++ b/bundle-uri.c\n> @@ -210,9 +210,17 @@ static int bundle_list_update(const char *key, const char *value,\n>  \tstrbuf_release(&id);\n\nOkay. The only other allocated variable was released already, so nothing\nthat we'd have to do in that case.\n\n>  \tif (!strcmp(subkey, \"uri\")) {\n> +\t\tstruct strbuf err = STRBUF_INIT;\n> +\n>  \t\tif (bundle->uri)\n>  \t\t\treturn -1;\n> -\t\tbundle->uri = relative_url(list->baseURI, value, NULL);\n> +\t\tbundle->uri = relative_url_gently(list->baseURI, value, NULL,\n> +\t\t\t\t\t\t  &err);\n> +\t\tif (!bundle->uri) {\n> +\t\t\terror(\"%s\", err.buf);\n> +\t\t\tstrbuf_release(&err);\n> +\t\t\treturn -1;\n> +\t\t}\n>  \t\treturn 0;\n>  \t}\n\nLooks reasonable. There's already other branches here that may return\nerrors, so any caller that wouldn't know to hanlde such an error would\nalready be broken right now.\n\n> diff --git a/remote.c b/remote.c\n> index 49ee2ea318..7472c426aa 100644\n> --- a/remote.c\n> +++ b/remote.c\n> @@ -3073,8 +3077,16 @@ char *relative_url(const char *remote_url, const char *url,\n>  \t */\n>  \twhile (*url) {\n>  \t\tif (starts_with_dot_dot_slash_native(url)) {\n> +\t\t\tint chopped;\n> +\n>  \t\t\turl += 3;\n> -\t\t\tcolonsep |= chop_last_dir(&remoteurl, is_relative);\n> +\t\t\tchopped = chop_last_dir(&remoteurl, is_relative, err);\n> +\t\t\tif (chopped < 0) {\n> +\t\t\t\tfree(remoteurl);\n> +\t\t\t\tstrbuf_release(&sb);\n> +\t\t\t\treturn NULL;\n> +\t\t\t}\n> +\t\t\tcolonsep |= chopped;\n\nThe error handling does get a bit unwieldy in this function by now. It\nwould have been great to maybe add a preparatory commit where we adapt\nit to have a single unified exit path that releases memory. But I won't\ninsist on it.\n\n> diff --git a/t/t5750-bundle-uri-parse.sh b/t/t5750-bundle-uri-parse.sh\n> index 70ae94c4d0..0f0ac29565 100755\n> --- a/t/t5750-bundle-uri-parse.sh\n> +++ b/t/t5750-bundle-uri-parse.sh\n> @@ -68,17 +68,16 @@ test_expect_success 'bundle_uri_parse_line(): relative URIs and parent paths' '\n>  \t\turi = <uri>/bundle.bdl\n>  \t[bundle \"two\"]\n>  \t\turi = bundle.bdl\n> -\t[bundle \"three\"]\n> -\t\turi = <uri>/../bundle.bdl\n\nWhy do we have to drop these lines here? Interestingly, we don't seem to\nuse this file at all in this test.\n\n>  \tEOF\n>  \n> -\t# TODO: We would prefer if parsing a bundle list would not cause\n> -\t# a die() and instead would give a warning and allow the rest of\n> -\t# a Git command to continue. This test_must_fail is necessary for\n> -\t# now until the interface for relative_url() allows for reporting\n> -\t# an error instead of die()ing.\n> +\tcat >err.expect <<-\\EOF &&\n> +\terror: cannot strip one component off url '\\''.'\\''\n\nThis error message doesn't really look useful to me. In the current form\nthe user wouldn't be able to figure out which URL specifically we failed\nto strip. It's a preexisting issue, true, but do we maybe want to fix it\nwhile at it?\n\nThanks!\n\nPatrick\n\n"},{"id":"557327","messageId":"20261103155231.381-1-aniketgupta3001@gmail.com","threadId":"66689","inReplyTo":"20261028115818.410-1-aniketgupta3001@gmail.com","subject":"[PATCH v2] bundle-uri: do not die on unresolvable relative URIs","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-11-03T15:52:31Z","receivedAt":"2026-11-03T15:52:31Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"A bundle list, either advertised by a server or given to \"git clone\n--bundle-uri\", may contain relative URIs. relative_url() resolves them\nand calls die() when there are more \"../\" components than the base can\nabsorb, so one bad entry aborts the whole clone.\n\nAdd relative_url_gently() which returns NULL and records the reason in\na strbuf instead of dying. relative_url() keeps dying, so the submodule\ncallers are unchanged. bundle_list_update() reports the problem as an\nerror and leaves the bundle without a URI. The download code already\nskips such a bundle, so the clone carries on with the others.\n\nName the URL in the error message, without any credentials, and update\nthe tests.\n\nSigned-off-by: Aniket Gupta <aniketgupta3001@gmail.com>\n---\nChanges since v1:\n - the commit message says which lists are meant and why carrying on\n   is fine\n - the error now names the URL that could not be resolved, with any\n   credentials removed\n - add a test for that in t0060\n\n bundle-uri.c                | 10 +++++++++-\n remote.c                    | 37 +++++++++++++++++++++++++++++++------\n remote.h                    |  8 ++++++++\n t/t0060-path-utils.sh       |  7 +++++++\n t/t5750-bundle-uri-parse.sh | 15 +++++++--------\n 5 files changed, 62 insertions(+), 15 deletions(-)\n\ndiff --git a/bundle-uri.c b/bundle-uri.c\nindex 2bb2eb99e4..1f198ef9a9 100644\n--- a/bundle-uri.c\n+++ b/bundle-uri.c\n@@ -210,9 +210,17 @@ static int bundle_list_update(const char *key, const char *value,\n \tstrbuf_release(&id);\n \n \tif (!strcmp(subkey, \"uri\")) {\n+\t\tstruct strbuf err = STRBUF_INIT;\n+\n \t\tif (bundle->uri)\n \t\t\treturn -1;\n-\t\tbundle->uri = relative_url(list->baseURI, value, NULL);\n+\t\tbundle->uri = relative_url_gently(list->baseURI, value, NULL,\n+\t\t\t\t\t\t  &err);\n+\t\tif (!bundle->uri) {\n+\t\t\terror(\"%s\", err.buf);\n+\t\t\tstrbuf_release(&err);\n+\t\t\treturn -1;\n+\t\t}\n \t\treturn 0;\n \t}\n \ndiff --git a/remote.c b/remote.c\nindex 49ee2ea318..36834b129c 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -3005,7 +3005,8 @@ void remote_state_clear(struct remote_state *remote_state)\n }\n \n /*\n- * Returns 1 if it was the last chop before ':'.\n+ * Returns 1 if it was the last chop before ':', or -1 if there is\n+ * nothing left to chop.\n  */\n static int chop_last_dir(char **remoteurl, int is_relative)\n {\n@@ -3022,16 +3023,15 @@ static int chop_last_dir(char **remoteurl, int is_relative)\n \t}\n \n \tif (is_relative || !strcmp(\".\", *remoteurl))\n-\t\tdie(_(\"cannot strip one component off url '%s'\"),\n-\t\t\t*remoteurl);\n+\t\treturn -1;\n \n \tfree(*remoteurl);\n \t*remoteurl = xstrdup(\".\");\n \treturn 0;\n }\n \n-char *relative_url(const char *remote_url, const char *url,\n-\t\t   const char *up_path)\n+char *relative_url_gently(const char *remote_url, const char *url,\n+\t\t\t  const char *up_path, struct strbuf *err)\n {\n \tint is_relative = 0;\n \tint colonsep = 0;\n@@ -3073,8 +3073,22 @@ char *relative_url(const char *remote_url, const char *url,\n \t */\n \twhile (*url) {\n \t\tif (starts_with_dot_dot_slash_native(url)) {\n+\t\t\tint chopped;\n+\n \t\t\turl += 3;\n-\t\t\tcolonsep |= chop_last_dir(&remoteurl, is_relative);\n+\t\t\tchopped = chop_last_dir(&remoteurl, is_relative);\n+\t\t\tif (chopped < 0) {\n+\t\t\t\tchar *anon = transport_anonymize_url(remote_url);\n+\n+\t\t\t\tstrbuf_addf(err,\n+\t\t\t\t\t    _(\"cannot strip one component off url '%s'\"),\n+\t\t\t\t\t    anon);\n+\t\t\t\tfree(anon);\n+\t\t\t\tfree(remoteurl);\n+\t\t\t\tstrbuf_release(&sb);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\tcolonsep |= chopped;\n \t\t} else if (starts_with_dot_slash_native(url))\n \t\t\turl += 2;\n \t\telse\n@@ -3102,6 +3116,17 @@ char *relative_url(const char *remote_url, const char *url,\n \treturn strbuf_detach(&sb, NULL);\n }\n \n+char *relative_url(const char *remote_url, const char *url,\n+\t\t   const char *up_path)\n+{\n+\tstruct strbuf err = STRBUF_INIT;\n+\tchar *out = relative_url_gently(remote_url, url, up_path, &err);\n+\n+\tif (!out)\n+\t\tdie(\"%s\", err.buf);\n+\treturn out;\n+}\n+\n int valid_remote_name(const char *name)\n {\n \tint result;\ndiff --git a/remote.h b/remote.h\nindex cca02033b9..940474fa71 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -478,6 +478,14 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);\n char *relative_url(const char *remote_url, const char *url,\n \t\t   const char *up_path);\n \n+/*\n+ * Like relative_url(), but if `url` cannot be resolved against\n+ * `remote_url`, return NULL and add the reason to `err` instead of\n+ * dying. `err` must not be NULL.\n+ */\n+char *relative_url_gently(const char *remote_url, const char *url,\n+\t\t\t  const char *up_path, struct strbuf *err);\n+\n int valid_remote_name(const char *name);\n \n #endif\ndiff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh\nindex 56faf5fe73..50cc37bc98 100755\n--- a/t/t0060-path-utils.sh\n+++ b/t/t0060-path-utils.sh\n@@ -394,6 +394,13 @@ test_submodule_relative_url \"../\" \"$(pwd)/addtest\" \"../repo\" \"$(pwd)/repo\"\n test_submodule_relative_url \"../\" \"foo/bar\" \"../submodule\" \"../foo/submodule\"\n test_submodule_relative_url \"../\" \"foo\" \"../submodule\" \"../submodule\"\n \n+test_expect_success 'relative_url() does not show credentials when it fails' '\n+\ttest_must_fail test-tool submodule resolve-relative-url \"\" \\\n+\t\t\"https://user:secret@host.example/a\" ../../../../../../x 2>err &&\n+\ttest_grep \"cannot strip one component off url\" err &&\n+\ttest_grep ! secret err\n+'\n+\n test_submodule_relative_url \"(null)\" \"../foo/bar\" \"../sub/a/b/c\" \"../foo/sub/a/b/c\"\n test_submodule_relative_url \"(null)\" \"../foo/bar\" \"../sub/a/b/c/\" \"../foo/sub/a/b/c\"\n test_submodule_relative_url \"(null)\" \"../foo/bar/\" \"../sub/a/b/c\" \"../foo/sub/a/b/c\"\ndiff --git a/t/t5750-bundle-uri-parse.sh b/t/t5750-bundle-uri-parse.sh\nindex 70ae94c4d0..8abf8f31ae 100755\n--- a/t/t5750-bundle-uri-parse.sh\n+++ b/t/t5750-bundle-uri-parse.sh\n@@ -68,17 +68,16 @@ test_expect_success 'bundle_uri_parse_line(): relative URIs and parent paths' '\n \t\turi = <uri>/bundle.bdl\n \t[bundle \"two\"]\n \t\turi = bundle.bdl\n-\t[bundle \"three\"]\n-\t\turi = <uri>/../bundle.bdl\n \tEOF\n \n-\t# TODO: We would prefer if parsing a bundle list would not cause\n-\t# a die() and instead would give a warning and allow the rest of\n-\t# a Git command to continue. This test_must_fail is necessary for\n-\t# now until the interface for relative_url() allows for reporting\n-\t# an error instead of die()ing.\n+\tcat >err.expect <<-\\EOF &&\n+\terror: cannot strip one component off url '\\''<uri>'\\''\n+\terror: bad line: '\\''bundle.three.uri=../../bundle.bdl'\\''\n+\tEOF\n+\n \ttest_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&\n-\ttest_grep \"fatal: cannot strip one component off url\" err\n+\ttest_cmp err.expect err &&\n+\ttest_cmp_config_output expect actual\n '\n \n test_expect_success 'bundle_uri_parse_line() parsing edge cases: empty key or value' '\n-- \n2.43.0\n\n\n"},{"id":"557328","messageId":"20261103155600.454-1-aniketgupta3001@gmail.com","threadId":"66689","inReplyTo":"aunb6OjWKWLyl-mp@pks.im","subject":"Re: [PATCH] bundle-uri: do not die on unresolvable relative URIs","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-11-03T15:55:59Z","receivedAt":"2026-11-03T15:55:59Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"On Tue, Nov 03, 2026 at 02:04:49PM +0100, Patrick Steinhardt wrote:\n> On Wed, Oct 28, 2026 at 11:58:18AM +0000, Aniket Gupta wrote:\n> > relative_url() calls die() when the relative URL has more \"../\"\n> > components than the remote URL can absorb. bundle_list_update() calls\n> > it on URIs taken from a bundle list and a single bad entry takes down\n> > the whole command.\n>\n> Which command?\n\ngit clone, with a bundle list from the server or from --bundle-uri.\nFetch uses the same code, but I only tried clone.\n\n> > Add relative_url_gently() which returns NULL and records the reason in\n> > a strbuf instead of dying. This will keep relative_url() as a wrapper\n>\n> s/will keep/keeps/. We're in present tense.\n\nFixed.\n\n> These \"bundle lists\" are quite abstract here. It would help the reader\n> if the commit message briefly mentioned where such a list even comes\n> from.\n\nAdded.\n\n> Even more importantly though, do we now only print the error and then\n> die or do we continue? And if the latter, why is it fine to continue\n> even if we have failed to retrieve the bundle? And is it fine to\n> continue for both callers of this function?\n\nWe continue. The bad entry ends up without a uri and the download code\nalready skips those. I tried both ways of getting a list with a too-deep\n../. The clone prints the errors and still finishes.\n\n> > +                     chopped = chop_last_dir(&remoteurl, is_relative, err);\n> > +                     if (chopped < 0) {\n> > +                             free(remoteurl);\n> > +                             strbuf_release(&sb);\n> > +                             return NULL;\n> > +                     }\n> > +                     colonsep |= chopped;\n>\n> The error handling does get a bit unwieldy in this function by now. It\n> would have been great to maybe add a preparatory commit where we adapt\n> it to have a single unified exit path that releases memory. But I won't\n> insist on it.\n\nI'd rather keep this one small. There is only one error path for now,\nso I left the cleanup out. Happy to send it as a separate patch if you\nprefer.\n\n> > -     [bundle \"three\"]\n> > -             uri = <uri>/../bundle.bdl\n>\n> Why do we have to drop these lines here? Interestingly, we don't seem to\n> use this file at all in this test.\n\nThe old expect was never compared because the test only checked for the\ndie(). Now it is compared and the bad bundle is not in it.\n\n> > +     error: cannot strip one component off url '\\''.'\\''\n>\n> This error message doesn't really look useful to me. In the current form\n> the user wouldn't be able to figure out which URL specifically we failed\n> to strip. It's a preexisting issue, true, but do we maybe want to fix it\n> while at it?\n\nGood point. It names the url now. I strip any user:password from it\nfirst so that it doesnt leak credentials.\n\n"},{"id":"557544","messageId":"auyH8BGzIsipPAJG@pks.im","threadId":"66689","inReplyTo":"20261103155231.381-1-aniketgupta3001@gmail.com","subject":"Re: [PATCH v2] bundle-uri: do not die on unresolvable relative URIs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-05T13:43:12Z","receivedAt":"2026-11-05T13:43:12Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Nov 03, 2026 at 03:52:31PM +0000, Aniket Gupta wrote:\n> A bundle list, either advertised by a server or given to \"git clone\n> --bundle-uri\", may contain relative URIs. relative_url() resolves them\n> and calls die() when there are more \"../\" components than the base can\n> absorb, so one bad entry aborts the whole clone.\n\nThanks, this gives much better context now compared to v1.\n\n> Add relative_url_gently() which returns NULL and records the reason in\n> a strbuf instead of dying. relative_url() keeps dying, so the submodule\n> callers are unchanged.\n\nThis sentence is weird as it adds context that doesn't make sense\nstandalone. You wouldn't know that there are submodule callers, so why\ndo you suddenly make the jump talking about them? And it immediately\nmakes you wonder about other callers.\n\nSaying something like \"relative_url() is now a thin wrapper around that\nnew function that continues to die, so existing callers continue to\nbehave the same\" would be way less surprising.\n\n> bundle_list_update() reports the problem as an error and leaves the\n> bundle without a URI. The download code already skips such a bundle,\n> so the clone carries on with the others.\n> \n> Name the URL in the error message, without any credentials, and update\n> the tests.\n\nWould it have made sense to split this out into a separate commit?\n\n> diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh\n> index 56faf5fe73..50cc37bc98 100755\n> --- a/t/t0060-path-utils.sh\n> +++ b/t/t0060-path-utils.sh\n> @@ -394,6 +394,13 @@ test_submodule_relative_url \"../\" \"$(pwd)/addtest\" \"../repo\" \"$(pwd)/repo\"\n>  test_submodule_relative_url \"../\" \"foo/bar\" \"../submodule\" \"../foo/submodule\"\n>  test_submodule_relative_url \"../\" \"foo\" \"../submodule\" \"../submodule\"\n>  \n> +test_expect_success 'relative_url() does not show credentials when it fails' '\n> +\ttest_must_fail test-tool submodule resolve-relative-url \"\" \\\n> +\t\t\"https://user:secret@host.example/a\" ../../../../../../x 2>err &&\n> +\ttest_grep \"cannot strip one component off url\" err &&\n> +\ttest_grep ! secret err\n> +'\n\nWouldn't it make sense in this case to grep for the exact URL printed,\nas the intent is to verify that we print the correct one? At that point,\nwe can probably just compare the full message.\n\nPatrick\n\n"},{"id":"557572","messageId":"20261105152906.566363-1-aniketgupta3001@gmail.com","threadId":"66689","inReplyTo":"auyH8BGzIsipPAJG@pks.im","subject":"Re: [PATCH v2] bundle-uri: do not die on unresolvable relative URIs","fromName":"Aniket Gupta","fromEmail":"aniketgupta3001@gmail.com","sentAt":"2026-11-05T15:29:06Z","receivedAt":"2026-11-05T15:29:06Z","isPatch":true,"sender":{"key":"aniketgupta3001@gmail.com","avatar":null},"body":"Hi Patrick,\n\nThanks for the review.\n\n> This sentence is weird as it adds context that doesn't make sense\n> standalone. [...] Saying something like \"relative_url() is now a thin\n> wrapper around that new function that continues to die, so existing\n> callers continue to behave the same\" would be way less surprising.\n\nMakes sense, I used your wording.\n\n> Would it have made sense to split this out into a separate commit?\n\nYes, I think so. It is three patches now: add relative_url_gently(),\nhide the credentials in its error message, and then use it in\nbundle-uri.\n\n> Wouldn't it make sense in this case to grep for the exact URL\n> printed, as the intent is to verify that we print the correct one? At\n> that point, we can probably just compare the full message.\n\nAgreed, the test compares the whole message now.\n\nAniket\n\n"}]}