From: Junio C Hamano Date: Thu, 17 Feb 2022 22:12:20 GMT Subject: Re: [PATCH v2 3/7] fetch: control lifecycle of FETCH_HEAD in a single place Message-ID: In-Reply-To: <0b9d04622d095f97246ae2603e2cb5312a68def3.1645102965.git.ps@pks.im> Patrick Steinhardt writes: > 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. OK. Each call to store_updated_refs() used to be responsible for opening, appending, committing, and closing FETCH_HEAD. We now make do_fetch() responsible for opening, committing, and closing, and let the direct and indirect callers of fetch_and_consume_refs() only worry about appending to it. Makes sense.