]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/fetch.c
fetch: centralize logic to print remote URL
authorPatrick Steinhardt <ps@pks.im>
Mon, 20 Mar 2023 12:35:36 +0000 (13:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Mar 2023 18:02:43 +0000 (11:02 -0700)
commitc4ef5edbc952302097d6a55ac490bad7726bf840
treebacc18a8e1101b8811caf0d32d4558a257ca1439
parent331b7d29f05b62fc73f1218e0e6db6969481a3cd
fetch: centralize logic to print remote URL

When fetching from a remote, we not only print the actual references
that have changed, but will also print the URL from which we have
fetched them to standard output. The logic to handle this is duplicated
across two different callsites with some non-trivial logic to compute
the anonymized URL. Furthermore, we're using global state to track
whether we have already shown the URL to the user or not.

Refactor the code by moving it into `format_display()`. Like this, we
can convert the global variable into a member of `display_state`. And
second, we can deduplicate the logic to compute the anonymized URL.

This also works as expected when fetching from multiple remotes, for
example via a group of remotes, as we do this by forking a standalone
git-fetch(1) process per remote that is to be fetched.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c