git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] builtin/fsmonitor--daemon: use parse-options API fully
@ 2021-08-17 10:27 Carlo Marcelo Arenas Belón
  2021-08-17 18:03 ` Jeff Hostetler
  0 siblings, 1 reply; 2+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2021-08-17 10:27 UTC (permalink / raw)
  To: git; +Cc: jeffhost, Carlo Marcelo Arenas Belón

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] builtin/fsmonitor--daemon: use parse-options API fully
  2021-08-17 10:27 [PATCH] builtin/fsmonitor--daemon: use parse-options API fully Carlo Marcelo Arenas Belón
@ 2021-08-17 18:03 ` Jeff Hostetler
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Hostetler @ 2021-08-17 18:03 UTC (permalink / raw)
  To: Carlo Marcelo Arenas Belón, git; +Cc: jeffhost



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 <carenas@gmail.com>
 > ...

Thanks again.  I'll take a look and squash this in.
Jeff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-17 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 10:27 [PATCH] builtin/fsmonitor--daemon: use parse-options API fully Carlo Marcelo Arenas Belón
2021-08-17 18:03 ` Jeff Hostetler

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).