Re: [PATCH 1/8] builtin: pass repository to sub commands
- From
shejialuo <shejialuo@gmail.com>
- Date
- Nov 16, 2024, 12:49 UTC
- Message-ID
- <ZziU3wmP0pigGRRr@ArchLinux>
- In-Reply-To
- <20241115-374-refactor-midx-c-and-midx-write-c-to-not-depend-on-global-state-v1-1-761f8a2c7775@gmail.com>
On Fri, Nov 15, 2024 at 02:42:14PM +0100, Karthik Nayak wrote:
[snip]
Show 41 quoted lines
> 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.
Thanks, Jialuo