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

[PATCH 2/4] tag-verify: migrate to parse-options

From
Stephen Boyd <bebarino@gmail.com>
Date
Jul 8, 2009, 05:15 UTC
Message-ID
<1247030141-11695-3-git-send-email-bebarino@gmail.com>
In-Reply-To
<1247030141-11695-2-git-send-email-bebarino@gmail.com>
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

It may be nicer to die with a message like "Must give a tag to verify" or something when a tag isn't given, but that could probably be a later patch.

 builtin-verify-tag.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/builtin-verify-tag.c b/builtin-verify-tag.c
index 7f7fda4..9f482c2 100644
--- a/builtin-verify-tag.c
+++ b/builtin-verify-tag.c
@@ -10,9 +10,12 @@
 #include "tag.h"
 #include "run-command.h"
 #include <signal.h>
+#include "parse-options.h"
 
-static const char builtin_verify_tag_usage[] =
-		"git verify-tag [-v|--verbose] <tag>...";
+static const char * const verify_tag_usage[] = {
+		"git verify-tag [-v|--verbose] <tag>...",
+		NULL
+};
 
 #define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
 
@@ -89,17 +92,17 @@ static int verify_tag(const char *name, int verbose)
 int cmd_verify_tag(int argc, const char **argv, const char *prefix)
 {
 	int i = 1, verbose = 0, had_error = 0;
+	const struct option verify_tag_options[] = {
+		OPT__VERBOSE(&verbose),
+		OPT_END()
+	};
 
 	git_config(git_default_config, NULL);
 
-	if (argc > 1 &&
-	    (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose"))) {
-		verbose = 1;
-		i++;
-	}
-
+	argc = parse_options(argc, argv, prefix, verify_tag_options,
+			     verify_tag_usage, PARSE_OPT_KEEP_ARGV0);
 	if (argc <= i)
-		usage(builtin_verify_tag_usage);
+		usage_with_options(verify_tag_usage, verify_tag_options);
 
 	/* sometimes the program was terminated because this signal
 	 * was received in the process of writing the gpg input: */
-- 
1.6.3.3.385.g60647
Previous: Stephen BoydNext: Stephen Boyd
Message 3 of 9 in “Migrate simple builtins to parse-options”
  1. 0/4 Migrate simple builtins to parse-optionsStephen Boyd, Jul 8, 2009
  2. 1/4 write-tree: migrate to parse-optionsStephen Boyd, Jul 8, 2009
  3. 2/4 tag-verify: migrate to parse-optionsStephen Boyd, Jul 8, 2009
  4. 3/4 verify-pack: migrate to parse-optionsStephen Boyd, Jul 8, 2009
  5. 4/4 prune-packed: migrate to parse-optionsStephen Boyd, Jul 8, 2009
  6. Johannes SchindelinJul 9, 2009
  7. Stephen BoydJul 9, 2009
  8. Stephen BoydJul 9, 2009
  9. Stephen BoydJul 9, 2009

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.