From: Stephen Boyd <bebarino@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 4/4] prune-packed: migrate to parse-options
Date: Tue, 7 Jul 2009 22:15:41 -0700 [thread overview]
Message-ID: <1247030141-11695-5-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <1247030141-11695-4-git-send-email-bebarino@gmail.com>
Add --dry-run and --quiet to be more consistent with the rest of git.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Documentation/git-prune-packed.txt | 4 +++-
builtin-prune-packed.c | 29 ++++++++++++-----------------
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt
index b5f26ce..abfc6b6 100644
--- a/Documentation/git-prune-packed.txt
+++ b/Documentation/git-prune-packed.txt
@@ -8,7 +8,7 @@ git-prune-packed - Remove extra objects that are already in pack files
SYNOPSIS
--------
-'git prune-packed' [-n] [-q]
+'git prune-packed' [-n|--dry-run] [-q|--quiet]
DESCRIPTION
@@ -28,10 +28,12 @@ disk storage, etc.
OPTIONS
-------
-n::
+--dry-run::
Don't actually remove any objects, only show those that would have been
removed.
-q::
+--quiet::
Squelch the progress indicator.
Author
diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c
index 00590b1..be99eb0 100644
--- a/builtin-prune-packed.c
+++ b/builtin-prune-packed.c
@@ -1,9 +1,12 @@
#include "builtin.h"
#include "cache.h"
#include "progress.h"
+#include "parse-options.h"
-static const char prune_packed_usage[] =
-"git prune-packed [-n] [-q]";
+static const char * const prune_packed_usage[] = {
+ "git prune-packed [-n|--dry-run] [-q|--quiet]",
+ NULL
+};
#define DRY_RUN 01
#define VERBOSE 02
@@ -68,24 +71,16 @@ void prune_packed_objects(int opts)
int cmd_prune_packed(int argc, const char **argv, const char *prefix)
{
- int i;
int opts = VERBOSE;
+ const struct option prune_packed_options[] = {
+ OPT_BIT('n', "dry-run", &opts, "dry run", DRY_RUN),
+ OPT_NEGBIT('q', "quiet", &opts, "be quiet", VERBOSE),
+ OPT_END()
+ };
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
+ argc = parse_options(argc, argv, prefix, prune_packed_options,
+ prune_packed_usage, 0);
- if (*arg == '-') {
- if (!strcmp(arg, "-n"))
- opts |= DRY_RUN;
- else if (!strcmp(arg, "-q"))
- opts &= ~VERBOSE;
- else
- usage(prune_packed_usage);
- continue;
- }
- /* Handle arguments here .. */
- usage(prune_packed_usage);
- }
prune_packed_objects(opts);
return 0;
}
--
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 ` [PATCH 3/4] verify-pack: " Stephen Boyd
2009-07-08 5:15 ` Stephen Boyd [this message]
2009-07-09 10:51 ` [PATCH 4/4] prune-packed: " 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-5-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).