[PATCH 1/9] builtin-verify-tag.c: use parse_options()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michele Ballabio <barra_cuda@xxxxxxxxxxxx>
---
 builtin-verify-tag.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/builtin-verify-tag.c b/builtin-verify-tag.c
index 7d837f0..590038b 100644
--- a/builtin-verify-tag.c
+++ b/builtin-verify-tag.c
@@ -9,10 +9,13 @@
 #include "builtin.h"
 #include "tag.h"
 #include "run-command.h"
+#include "parse-options.h"
 #include <signal.h>
 
-static const char builtin_verify_tag_usage[] =
-		"git verify-tag [-v|--verbose] <tag>...";
+static const char * const builtin_verify_tag_usage[] = {
+	"git verify-tag [-v|--verbose] <tag>...",
+	NULL
+};
 
 #define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
 
@@ -88,23 +91,25 @@ 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;
+	int verbose = 0, had_error = 0;
 
 	git_config(git_default_config, NULL);
 
+	const struct option options[] = {
+		OPT__VERBOSE(&verbose),
+		OPT_END()
+	};
+
 	if (argc == 1)
-		usage(builtin_verify_tag_usage);
+		usage_with_options(builtin_verify_tag_usage, options);
 
-	if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) {
-		verbose = 1;
-		i++;
-	}
+	argc = parse_options(argc, argv, options, builtin_verify_tag_usage, 0);
 
 	/* sometimes the program was terminated because this signal
 	 * was received in the process of writing the gpg input: */
 	signal(SIGPIPE, SIG_IGN);
-	while (i < argc)
-		if (verify_tag(argv[i++], verbose))
+	while (argc-- > 0)
+		if (verify_tag(*argv++, verbose))
 			had_error = 1;
 	return had_error;
 }
-- 
1.5.6.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux