Re: [PATCH 3/6] fetch: control lifecycle of FETCH_HEAD in a single place
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Feb 15, 2022, 07:32 UTC
- Message-ID
- <CAP8UFD32MQSVQ2uUhmO29jFz=LfqvN8U7e-a=sDgQAxUh+Gadw@mail.gmail.com>
- In-Reply-To
- <4059d5034bd9137ffca4929ed5bd8b7ce75ea09c.1644565025.git.ps@pks.im>
On Sat, Feb 12, 2022 at 5:49 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 8 quoted lines
> > 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 code which
s/down to code/down to the code/
> wants to append to it.
Show 21 quoted lines
> @@ -1601,6 +1596,10 @@ static int do_fetch(struct transport *transport,
> if (!update_head_ok)
> check_not_current_branch(ref_map, worktrees);
>
> + retcode = open_fetch_head(&fetch_head);
> + if (retcode)
> + goto cleanup;
> +
> if (tags == TAGS_DEFAULT && autotags)
> transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
> if (prune) {
> @@ -1617,7 +1616,8 @@ static int do_fetch(struct transport *transport,
> transport->url);
> }
> }
> - if (fetch_and_consume_refs(transport, ref_map, worktrees)) {
> +
> + if (fetch_and_consume_refs(transport, ref_map, &fetch_head, worktrees)) {
> retcode = 1;
> goto cleanup;
> }I think the following (if it works) would be more consistent with what's done for open_fetch_head() above:
retcode = fetch_and_consume_refs(transport, ref_map, &fetch_head, worktrees)
if (retcode)
goto cleanup;