Re: [PATCH 11/16] promisor-remote: refactor should_accept_remote() control flow
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Apr 2, 2026, 06:55 UTC
- Message-ID
- <CAP8UFD1G2np6dJX_J6-5-Pxn=j_GgJ2BVdDkaxVw34EU6DDCLQ@mail.gmail.com>
- In-Reply-To
- <acUkwrm1rN4l4qgP@pks.im>
On Thu, Mar 26, 2026 at 1:21 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 22 quoted lines
>
> On Mon, Mar 23, 2026 at 09:05:14AM +0100, Christian Couder wrote:
> > diff --git a/promisor-remote.c b/promisor-remote.c
> > index 8f2c1280c3..c2f0eb7223 100644
> > --- a/promisor-remote.c
> > +++ b/promisor-remote.c
> > @@ -665,6 +665,12 @@ static int should_accept_remote(enum accept_promisor accept,
> > const char *remote_name = advertised->name;
> > const char *remote_url = advertised->url;
> >
> > + if (!remote_url || !*remote_url) {
> > + warning(_("no or empty URL advertised for remote '%s', "
> > + "ignoring this remote"), remote_name);
> > + return 0;
> > + }
> > +
> > if (accept == ACCEPT_ALL)
> > return all_fields_match(advertised, config_info, NULL);
>
> You mention that it shouldn't change behaviour in well-defined cases
> where the remote sends non-empty URLs. But does it change behaviour in
> ill-defined cases where the remote sends empty ones?Yes, it could change the behavior in the ill-defined case where the remote sends empty URLs.
So I have added a new patch to catch advertised empty URLs and empty remote names at parsing time. It is patch 4/10 ("promisor-remote: reject empty name or URL in advertised remote") in the preparatory series I will send very soon now.
> In other words, does this fix a bug that can be hit in the real world?
No, because I think Git has the only implementation of the "promisor-remote" capability, and a Git server doesn't advertise empty URLs. (promisor_config_info_list() ignores empty URLs.)
So the ill-defined case could only happen if people use their own fork of either Git (with a hacked the "promisor-remote" capability) or an implementation of Git (that implements the "promisor-remote" capability differently). So not likely in practice.
Thanks.