Re: [PATCH 4/5] pack-write: pass hash_algo to `write_rev_file()`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jan 16, 2025, 13:24 UTC
- Message-ID
- <Z4kIkY17fFDRrBdV@pks.im>
- In-Reply-To
- <20250116-kn-the-repo-cleanup-v1-4-a2f4c8e1c4c3@gmail.com>
On Thu, Jan 16, 2025 at 12:35:16PM +0100, Karthik Nayak via B4 Relay wrote:
Show 14 quoted lines
> From: Karthik Nayak <karthik.188@gmail.com> > > The `write_rev_file()` function uses the global `the_hash_algo` variable > to access the repository's hash function. To avoid global variable > usage, let's pass the hash function from the layers above. > > Altough the layers above could have access to the hash function > internally, simply pass in `the_hash_algo`. This avoids any > compatibility issues and bubbles up global variable usage to upper > layers which can be eventually resolved. > > However, in `midx-write.c`, since all usage of global variables is > removed, don't reintroduce them and instead use the `repo` available in > the context.
Yeah, this feels quite sensible. We know this file is supposedly `the_repository`-clean, and callers expect it to be, so reintroducing it wouldn't be sensible.
Patrick