git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] t/test-tool: handle -c <name>=<value> arguments

From
Rubén Justo <rjusto@gmail.com>
Date
Jan 9, 2024, 15:29 UTC
Message-ID
<6a4d6a56-ab6f-4557-a5a3-1713f57cbfc9@gmail.com>
In-Reply-To
<7c68392c-af2f-4999-ae64-63221bf7833a@gmail.com>

Soon we're going to need to pass configuration values to a command in test-tool.

Let's teach test-tool to take config values via command line arguments.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 t/helper/test-tool.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index d9f57c20db..7eba4ec9ab 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -3,9 +3,10 @@
 #include "test-tool-utils.h"
 #include "trace2.h"
 #include "parse-options.h"
+#include "config.h"
 
 static const char * const test_tool_usage[] = {
-	"test-tool [-C <directory>] <command> [<arguments>...]]",
+	"test-tool [-C <directory>] [-c <name>=<value>] <command> [<arguments>...]",
 	NULL
 };
 
@@ -106,6 +107,13 @@ static NORETURN void die_usage(void)
 	exit(128);
 }
 
+static int parse_config_option(const struct option *opt, const char *arg,
+			       int unset)
+{
+	git_config_push_parameter(arg);
+	return 0;
+}
+
 int cmd_main(int argc, const char **argv)
 {
 	int i;
@@ -113,6 +121,9 @@ int cmd_main(int argc, const char **argv)
 	struct option options[] = {
 		OPT_STRING('C', NULL, &working_directory, "directory",
 			   "change the working directory"),
+		OPT_CALLBACK('c', NULL, NULL, "<name>=<value>",
+			   "pass a configuration parameter to the command",
+			   parse_config_option),
 		OPT_END()
 	};
 
-- 
2.42.0
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 36 in “allow disabling the automatic hint in advise_if_enabled()”
  1. 0/3 allow disabling the automatic hint in advise_if_enabled()Rubén Justo, Jan 9, 2024
  2. 1/3 t/test-tool: usage descriptionRubén Justo, Jan 9, 2024
  3. Junio C HamanoJan 9, 2024
  4. 2/3 t/test-tool: handle -c <name>=<value> argumentsRubén Justo, Jan 9, 2024
  5. Junio C HamanoJan 9, 2024
  6. Taylor BlauJan 9, 2024
  7. 3/3 advice: allow disabling the automatic hint in advise_if_enabled()Rubén Justo, Jan 9, 2024
  8. Junio C HamanoJan 9, 2024
  9. Taylor BlauJan 9, 2024
  10. Junio C HamanoJan 9, 2024
  11. Rubén JustoJan 10, 2024
  12. Jeff KingJan 10, 2024
  13. Rubén JustoJan 10, 2024
  14. Dragan SimicJan 10, 2024
  15. Rubén JustoJan 10, 2024
  16. Dragan SimicJan 10, 2024
  17. Junio C HamanoJan 10, 2024
  18. Dragan SimicJan 10, 2024
  19. Jeff KingJan 11, 2024
  20. Dragan SimicJan 18, 2024
  21. Junio C HamanoJan 18, 2024
  22. Dragan SimicJan 18, 2024
  23. Junio C HamanoJan 18, 2024
  24. Dragan SimicJan 18, 2024
  25. Rubén JustoJan 20, 2024
  26. Dragan SimicJan 20, 2024
  27. Junio C HamanoJan 10, 2024
  28. Taylor BlauJan 9, 2024
  29. Junio C HamanoJan 9, 2024
  30. Rubén JustoJan 10, 2024
  31. advice: allow disabling the automatic hint in advise_if_enabled()Rubén Justo, Jan 12, 2024
  32. Junio C HamanoJan 12, 2024
  33. Jeff KingJan 13, 2024
  34. Junio C HamanoJan 16, 2024
  35. Rubén JustoJan 15, 2024
  36. advice: allow disabling the automatic hint in advise_if_enabled()Rubén Justo, Jan 15, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.