git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 2/2] usage: add warn_once() helper for repeated warnings

From
Derrick Stolee <derrickstolee@github.com>
Date
Jun 2, 2022, 13:43 UTC
Message-ID
<049aae88-f5b3-788e-3979-34e8178e6bd4@github.com>
In-Reply-To
<220601.86r148yxi3.gmgdl@evledraar.gmail.com>
On 6/1/2022 3:33 PM, Ævar Arnfjörð Bjarmason wrote:
Show 28 quoted lines
> 
> 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@github.com>
>>>>
>>>> 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:
... 
Show 22 quoted lines
> 	+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

Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 30 of 40 in “urlmatch: create fetch.credentialsInUrl config”
  1. urlmatch: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, May 23, 2022
  2. Junio C HamanoMay 23, 2022
  3. Derrick StoleeMay 23, 2022
  4. Junio C HamanoMay 23, 2022
  5. Johannes SchindelinMay 24, 2022
  6. Derrick StoleeMay 24, 2022
  7. Junio C HamanoMay 23, 2022
  8. Johannes SchindelinMay 24, 2022
  9. Ævar Arnfjörð BjarmasonMay 24, 2022
  10. Derrick StoleeMay 24, 2022
  11. Ævar Arnfjörð BjarmasonMay 24, 2022
  12. Derrick StoleeMay 25, 2022
  13. Johannes SchindelinMay 24, 2022
  14. Derrick StoleeMay 24, 2022
  15. urlmatch: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, May 27, 2022
  16. Ævar Arnfjörð BjarmasonMay 27, 2022
  17. Derrick StoleeMay 27, 2022
  18. Junio C HamanoMay 27, 2022
  19. Junio C HamanoMay 27, 2022
  20. Junio C HamanoMay 30, 2022
  21. Derrick StoleeMay 31, 2022
  22. 0/2 fetch: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, Jun 1, 2022
  23. 1/2 remote: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, Jun 1, 2022
  24. Ævar Arnfjörð BjarmasonJun 1, 2022
  25. Derrick StoleeJun 2, 2022
  26. 2/2 usage: add warn_once() helper for repeated warningsDerrick Stolee via GitGitGadget, Jun 1, 2022
  27. Ævar Arnfjörð BjarmasonJun 1, 2022
  28. Derrick StoleeJun 1, 2022
  29. Ævar Arnfjörð BjarmasonJun 1, 2022
  30. Derrick StoleeJun 2, 2022
  31. Junio C HamanoJun 1, 2022
  32. Derrick StoleeJun 2, 2022
  33. Junio C HamanoJun 2, 2022
  34. Junio C HamanoJun 1, 2022
  35. remote: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, Jun 2, 2022
  36. Junio C HamanoJun 2, 2022
  37. Derrick StoleeJun 3, 2022
  38. Junio C HamanoJun 6, 2022
  39. remote: create fetch.credentialsInUrl configDerrick Stolee via GitGitGadget, Jun 6, 2022
  40. Junio C HamanoJun 6, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.