From: Stephen Boyd <bebarino@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 3/4] verify-pack: migrate to parse-options
Date: Tue, 7 Jul 2009 22:15:40 -0700 [thread overview]
Message-ID: <1247030141-11695-4-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <1247030141-11695-3-git-send-email-bebarino@gmail.com>
OPT__VERBOSE adds a --verbose option, so document the new addition.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Documentation/git-verify-pack.txt | 3 +-
builtin-verify-pack.c | 40 ++++++++++++++++--------------------
2 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt
index c861163..d791a80 100644
--- a/Documentation/git-verify-pack.txt
+++ b/Documentation/git-verify-pack.txt
@@ -8,7 +8,7 @@ git-verify-pack - Validate packed git archive files
SYNOPSIS
--------
-'git verify-pack' [-v] [--] <pack>.idx ...
+'git verify-pack' [-v|--verbose] [--] <pack>.idx ...
DESCRIPTION
@@ -23,6 +23,7 @@ OPTIONS
The idx files to verify.
-v::
+--verbose::
After verifying the pack, show list of objects contained
in the pack.
\--::
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index 0ee0a9a..ebd6dff 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -2,6 +2,7 @@
#include "cache.h"
#include "pack.h"
#include "pack-revindex.h"
+#include "parse-options.h"
#define MAX_CHAIN 50
@@ -107,36 +108,31 @@ static int verify_one_pack(const char *path, int verbose)
return err;
}
-static const char verify_pack_usage[] = "git verify-pack [-v] <pack>...";
+static const char * const verify_pack_usage[] = {
+ "git verify-pack [-v|--verbose] <pack>...",
+ NULL
+};
int cmd_verify_pack(int argc, const char **argv, const char *prefix)
{
int err = 0;
int verbose = 0;
- int no_more_options = 0;
- int nothing_done = 1;
+ int i;
+ const struct option verify_pack_options[] = {
+ OPT__VERBOSE(&verbose),
+ OPT_END()
+ };
git_config(git_default_config, NULL);
- while (1 < argc) {
- if (!no_more_options && argv[1][0] == '-') {
- if (!strcmp("-v", argv[1]))
- verbose = 1;
- else if (!strcmp("--", argv[1]))
- no_more_options = 1;
- else
- usage(verify_pack_usage);
- }
- else {
- if (verify_one_pack(argv[1], verbose))
- err = 1;
- discard_revindex();
- nothing_done = 0;
- }
- argc--; argv++;
+ argc = parse_options(argc, argv, prefix, verify_pack_options,
+ verify_pack_usage, 0);
+ if (argc < 1)
+ usage_with_options(verify_pack_usage, verify_pack_options);
+ for (i = 0; i < argc; i++) {
+ if (verify_one_pack(argv[i], verbose))
+ err = 1;
+ discard_revindex();
}
- if (nothing_done)
- usage(verify_pack_usage);
-
return err;
}
--
1.6.3.3.385.g60647
next prev parent reply other threads:[~2009-07-08 5:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-08 5:15 [PATCH 0/4] Migrate simple builtins to parse-options Stephen Boyd
2009-07-08 5:15 ` [PATCH 1/4] write-tree: migrate " Stephen Boyd
2009-07-08 5:15 ` [PATCH 2/4] tag-verify: " Stephen Boyd
2009-07-08 5:15 ` Stephen Boyd [this message]
2009-07-08 5:15 ` [PATCH 4/4] prune-packed: " Stephen Boyd
2009-07-09 10:51 ` Johannes Schindelin
2009-07-09 15:55 ` Stephen Boyd
2009-07-09 16:05 ` Stephen Boyd
2009-07-09 16:01 ` [PATCH 3/4] verify-pack: " Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1247030141-11695-4-git-send-email-bebarino@gmail.com \
--to=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).