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

Subsystems: the rest

STALE1823d

2 messages, 2 authors, 2021-08-17 · open the first message on its own page

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

From: Carlo Marcelo Arenas Belón <hidden>
Date: 2021-08-17 10:27:59

--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 <redacted>
---
 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

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

From: Jeff Hostetler <hidden>
Date: 2021-08-17 18:03:11


On 8/17/21 6:27 AM, Carlo Marcelo Arenas Belón wrote:
--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 <redacted>
 > ...

Thanks again.  I'll take a look and squash this in.
Jeff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help