From: Derrick Stolee <derrickstolee@github.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
me@ttaylorr.com, christian.couder@gmail.com,
johannes.schindelin@gmx.de, jrnieder@gmail.com,
"brian m. carlson" <sandals@crustytoothpaste.net>,
Robert Coup <robert.coup@koordinates.com>
Subject: Re: [PATCH v3 2/2] usage: add warn_once() helper for repeated warnings
Date: Thu, 2 Jun 2022 09:43:33 -0400 [thread overview]
Message-ID: <049aae88-f5b3-788e-3979-34e8178e6bd4@github.com> (raw)
In-Reply-To: <220601.86r148yxi3.gmgdl@evledraar.gmail.com>
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@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:
...
> +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
next prev parent reply other threads:[~2022-06-02 13:43 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 18:04 [PATCH] urlmatch: create fetch.credentialsInUrl config Derrick Stolee via GitGitGadget
2022-05-23 19:06 ` Junio C Hamano
2022-05-23 20:31 ` Derrick Stolee
2022-05-23 21:14 ` Junio C Hamano
2022-05-24 11:46 ` Johannes Schindelin
2022-05-24 20:14 ` Derrick Stolee
2022-05-23 20:37 ` Junio C Hamano
2022-05-24 11:51 ` Johannes Schindelin
2022-05-24 8:18 ` Ævar Arnfjörð Bjarmason
2022-05-24 13:50 ` Derrick Stolee
2022-05-24 21:01 ` Ævar Arnfjörð Bjarmason
2022-05-25 14:03 ` Derrick Stolee
2022-05-24 11:42 ` Johannes Schindelin
2022-05-24 20:16 ` Derrick Stolee
2022-05-27 13:27 ` [PATCH v2] " Derrick Stolee via GitGitGadget
2022-05-27 14:22 ` Ævar Arnfjörð Bjarmason
2022-05-27 14:43 ` Derrick Stolee
2022-05-27 18:09 ` Junio C Hamano
2022-05-27 18:40 ` Junio C Hamano
2022-05-30 0:16 ` Junio C Hamano
2022-05-31 13:32 ` Derrick Stolee
2022-06-01 1:16 ` [PATCH v3 0/2] fetch: " Derrick Stolee via GitGitGadget
2022-06-01 1:16 ` [PATCH v3 1/2] remote: " Derrick Stolee via GitGitGadget
2022-06-01 19:19 ` Ævar Arnfjörð Bjarmason
2022-06-02 13:38 ` Derrick Stolee
2022-06-01 1:16 ` [PATCH v3 2/2] usage: add warn_once() helper for repeated warnings Derrick Stolee via GitGitGadget
2022-06-01 12:29 ` Ævar Arnfjörð Bjarmason
2022-06-01 18:42 ` Derrick Stolee
2022-06-01 19:33 ` Ævar Arnfjörð Bjarmason
2022-06-02 13:43 ` Derrick Stolee [this message]
2022-06-01 20:21 ` Junio C Hamano
2022-06-02 14:24 ` Derrick Stolee
2022-06-02 17:53 ` Junio C Hamano
2022-06-01 20:40 ` Junio C Hamano
2022-06-02 17:20 ` [PATCH v4] remote: create fetch.credentialsInUrl config Derrick Stolee via GitGitGadget
2022-06-02 21:20 ` Junio C Hamano
2022-06-03 12:54 ` Derrick Stolee
2022-06-06 15:37 ` Junio C Hamano
2022-06-06 14:36 ` [PATCH v5] " Derrick Stolee via GitGitGadget
2022-06-06 16:34 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=049aae88-f5b3-788e-3979-34e8178e6bd4@github.com \
--to=derrickstolee@github.com \
--cc=avarab@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=jrnieder@gmail.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=robert.coup@koordinates.com \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).