fetch: control lifecycle of FETCH_HEAD in a single place
commit2983cec0f26b7409ccc2dd5710b40ff4809cd4b1
authorPatrick Steinhardt <ps@pks.im>
Thu, 17 Feb 2022 13:04:24 +0000 (17 14:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Feb 2022 19:19:43 +0000 (17 11:19 -0800)
treeda5606ff76166b0021b3e8a375a7a43d94ef7223
parentefbade066083eb0a8ccee5a8290cd3fc834705f3
fetch: control lifecycle of FETCH_HEAD in a single place

There are two different locations where we're appending to FETCH_HEAD:
first when storing updated references, and second when backfilling tags.
Both times we open the file, append to it and then commit it into place,
which is essentially duplicate work.

Improve the lifecycle of updating FETCH_HEAD by opening and committing
it once in `do_fetch()`, where we pass the structure down to the code
which wants to append to it.

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