Re: [PATCH v2 3/8] packfile: pass `repository` to static function in the file
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Oct 28, 2024, 16:12 UTC
- Message-ID
- <Zx+4CNUHks2VRMEn@nand.local>
- In-Reply-To
- <1f8ef580e5a62ac145501c124407f9bf399b5da2.1730122499.git.karthik.188@gmail.com>
On Mon, Oct 28, 2024 at 02:43:41PM +0100, Karthik Nayak wrote:
Show 19 quoted lines
> Some of the static functions in the `packfile.c` access global > variables, which can simply be avoiding by passing the `repository` > struct down to them. Let's do that. > > Signed-off-by: Karthik Nayak <karthik.188@gmail.com> > --- > packfile.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/packfile.c b/packfile.c > index 9b353db331..cc558f06cc 100644 > --- a/packfile.c > +++ b/packfile.c > @@ -460,13 +460,13 @@ static void find_lru_pack(struct packed_git *p, struct packed_git **lru_p, struc > *accept_windows_inuse = has_windows_inuse; > } > > -static int close_one_pack(void) > +static int close_one_pack(struct repository *repo)
Same note on naming this parameter as 'struct repository *r' instead of "repo".
Show 16 quoted lines
> {
> struct packed_git *p, *lru_p = NULL;
> struct pack_window *mru_w = NULL;
> int accept_windows_inuse = 1;
>
> - for (p = the_repository->objects->packed_git; p; p = p->next) {
> + for (p = repo->objects->packed_git; p; p = p->next) {
> if (p->pack_fd == -1)
> continue;
> find_lru_pack(p, &lru_p, &mru_w, &accept_windows_inuse);
> @@ -555,7 +555,7 @@ static int open_packed_git_1(struct packed_git *p)
> pack_max_fds = 1;
> }
>
> - while (pack_max_fds <= pack_open_fds && close_one_pack())
> + while (pack_max_fds <= pack_open_fds && close_one_pack(p->repo))Makes sense, as does the remainder of the patch. Looking good.
Thanks, Taylor