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

[PATCH] builtin/fsmonitor--daemon: use parse-options API fully

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Aug 17, 2021, 10:27 UTC
Message-ID
<20210817102710.23916-1-carenas@gmail.com>

--help and -h are already handled internally so just parse_options() do the parsing and extract the command from the remaining options.

as a side effect, avoid setting a variable argc to a value that was never used.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 builtin/fsmonitor--daemon.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index 25f18f2726..d6a6010512 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1511,20 +1511,13 @@ int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	if (argc < 2)
-		usage_with_options(builtin_fsmonitor__daemon_usage, options);
-
-	if (argc == 2 && !strcmp(argv[1], "-h"))
+	argc = parse_options(argc, argv, prefix, options,
+			     builtin_fsmonitor__daemon_usage, 0);
+	if (argc != 1)
 		usage_with_options(builtin_fsmonitor__daemon_usage, options);
+	subcmd = argv[0];
 
 	git_config(fsmonitor_config, NULL);
-
-	subcmd = argv[1];
-	argv--;
-	argc++;
-
-	argc = parse_options(argc, argv, prefix, options,
-			     builtin_fsmonitor__daemon_usage, 0);
 	if (fsmonitor__ipc_threads < 1)
 		die(_("invalid 'ipc-threads' value (%d)"),
 		    fsmonitor__ipc_threads);
-- 
2.33.0.476.gf000ecbed9
Next: Jeff Hostetler
Message 1 of 2 in “builtin/fsmonitor--daemon: use parse-options API fully”
  1. builtin/fsmonitor--daemon: use parse-options API fullyCarlo Marcelo Arenas Belón, Aug 17, 2021
  2. Jeff HostetlerAug 17, 2021

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.