Re: [PATCH 1/8] builtin: pass repository to sub commands
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Nov 18, 2024, 08:05 UTC
- Message-ID
- <Zzr1YaDIjweaMOm6@pks.im>
- In-Reply-To
- <ZziU3wmP0pigGRRr@ArchLinux>
On Sat, Nov 16, 2024 at 08:49:35PM +0800, shejialuo wrote:
Show 50 quoted lines
> On Fri, Nov 15, 2024 at 02:42:14PM +0100, Karthik Nayak wrote:
>
> [snip]
>
> > diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
> > index 5250913d99eba18a28878d3904cb7b2399670d02..e5b1fe287e3ec94f0d8a3a99adb68842d52992f6 100644
> > --- a/t/helper/test-parse-options.c
> > +++ b/t/helper/test-parse-options.c
> > @@ -1,8 +1,11 @@
> > +#define USE_THE_REPOSITORY_VARIABLE
> > +
> > #include "test-tool.h"
> > #include "parse-options.h"
> > #include "strbuf.h"
> > #include "string-list.h"
> > #include "trace2.h"
> > +#include "repository.h"
> >
> > static int boolean = 0;
> > static int integer = 0;
> > @@ -282,14 +285,16 @@ int cmd__parse_options_flags(int argc, const char **argv)
> > return parse_options_flags__cmd(argc, argv, test_flags);
> > }
> >
> > -static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)
> > +static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED,
> > + struct repository *repo UNUSED)
> > {
> > printf("fn: subcmd_one\n");
> > print_args(argc, argv);
> > return 0;
> > }
> >
> > -static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)
> > +static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED,
> > + struct repository *repo UNUSED)
> > {
> > printf("fn: subcmd_two\n");
> > print_args(argc, argv);
> > @@ -319,7 +324,7 @@ static int parse_subcommand__cmd(int argc, const char **argv,
> >
> > printf("opt: %d\n", opt);
> >
> > - return fn(argc, argv, NULL);
> > + return fn(argc, argv, NULL, the_repository);
>
> Do we need to pass the real "the_repository" variable here. From my
> understanding, we could just pass `NULL` to avoid including the
> "repository.h" and the macro. However, I am not familiar with the
> "test-tool" helper. It my comment was wrong, please ignore.It certainly is surprising. If this really is required I'd expect an explanation in the commit message.
Patrick