]> git.ipfire.org Git - thirdparty/git.git/commit
fetch: centralize handling of per-reference format
authorPatrick Steinhardt <ps@pks.im>
Mon, 20 Mar 2023 12:35:32 +0000 (13:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Mar 2023 18:02:43 +0000 (11:02 -0700)
commit331b7d29f05b62fc73f1218e0e6db6969481a3cd
treeec4b1ebda5ed482ed431ca824a93c87fc8deb7be
parent7c978db889f2a0eddf0799268f57b9457ef9ab3d
fetch: centralize handling of per-reference format

The function `format_display()` is used to print a single reference
update to a buffer which will then ultimately be printed by the caller.
This architecture causes us to duplicate some logic across the different
callsites of this function. This makes it hard to follow the code as
some parts of the logic are located in one place, while other parts of
the logic are located in a different place. Furthermore, by having the
logic scattered around it becomes quite hard to implement a new output
format for the reference updates.

We can make the logic a whole lot easier to understand by making the
`format_display()` function self-contained so that it handles formatting
and printing of the references. This will eventually allow us to easily
implement a completely different output format, but also opens the door
to conditionally print to either stdout or stderr depending on the
output format.

As a first step towards that goal we move the formatting directive used
by both callers to print a single reference update into this function.

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