Thread (64 messages) 64 messages, 7 authors, 2024-11-27

Re: [PATCH 1/8] builtin: pass repository to sub commands

From: shejialuo <hidden>
Date: 2024-11-16 12:49:31

On Fri, Nov 15, 2024 at 02:42:14PM +0100, Karthik Nayak wrote:

[snip]
quoted hunk ↗ jump to hunk
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help