Re: [PATCH 3/3] add: pass in repo variable instead of global the_repository
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 6, 2024, 10:46 UTC
- Message-ID
- <ZtrdnFjFeWG7asio@pks.im>
- In-Reply-To
- <bc9090469340fe2bead812918d149287dcda5609.1725555468.git.gitgitgadget@gmail.com>
On Thu, Sep 05, 2024 at 04:57:47PM +0000, John Cai via GitGitGadget wrote:
> Fr> diff --git a/builtin/add.c b/builtin/add.c > index dac832df3e7..a68fd7c8313 100644 > --- a/builtin/add.c > +++ b/builtin/add.c
One thing I'm missing in this patch is it getting rid of `USE_THE_REPOSITORY_VARIABLE`. Without that change it is impossible to see whether we are now free of `the_repository` in this file.
Show 10 quoted lines
> @@ -36,24 +36,27 @@ static int pathspec_file_nul;
> static int include_sparse;
> static const char *pathspec_from_file;
>
> -static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
> +static int chmod_pathspec(struct pathspec *pathspec,
> + char flip,
> + int show_only,
> + struct repository *repo)
> {Nit: We typically tend to pass the repository as first argument. Also applies to all the other functions.
Show 12 quoted lines
> diff --git a/commit.h b/commit.h > index 0e5fce543c2..92fef717be1 100644 > --- a/commit.h > +++ b/commit.h > @@ -2,6 +2,7 @@ > #define COMMIT_H > > #include "object.h" > +#include "repository.h" > > struct signature_check; > struct strbuf;
There is no need for the include here, let's instead add a forward declaration.
Patrick