On 6/1/2022 3:33 PM, Ævar Arnfjörð Bjarmason wrote: > > On Wed, Jun 01 2022, Derrick Stolee wrote: > >> On 6/1/2022 8:29 AM, Ævar Arnfjörð Bjarmason wrote:> >>> On Wed, Jun 01 2022, Derrick Stolee via GitGitGadget wrote: >>> >>>> From: Derrick Stolee <derrickstolee@xxxxxxxxxx> >>>> >>>> The previous change added a warning when valid_remote() detects >>>> credentials in the URL. Since remotes are validated multiple times per >>>> process, this causes multiple warnings to print. >>> >>> Why are we validating remotes multiple times per process? Can't we just >>> do it once? >>> >>> Is this a case of two callers going through the whole machinery and not >>> being aware of one another? >>> >>> Perhaps it's a pain to deal with that in this case, but it would be >>> better to note why here than taking it as a given. >> >> We could certainly investigate this more, but it seems like a more >> problematic approach than the one taken here. We could add a "is_valid" >> bit to struct remote, but then could some code path modify that struct >> after it was validated? > > I tested this a bit and I think this alternate approach is simpler, and > it passes your tests: ... > +static void valid_remote_at_end(const struct remote *remote) > +{ > + int i; > + > + for (i = 0; i < remote->url_nr; i++) > + check_if_creds_in_url(remote->url[i]); > +} > + > static const char *alias_url(const char *url, struct rewrites *r) > { > int i, j; > @@ -687,6 +692,7 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name, > add_url_alias(remote_state, ret, name); > if (!valid_remote(ret)) > return NULL; > + valid_remote_at_end(ret); > return ret; > } > > I.e. we already have one spot where we get the full remote config, you > were just hooking into valid_remote() which we call N times while doing > that, let's just call it at the end. Thanks for finding a place where the current behavior only runs once. I agree that this is a much simpler approach and reduces this series back down to one. Thanks, -Stolee