Skip to content

Commit

Permalink
prune-packed: migrate to parse-options
Browse files Browse the repository at this point in the history
Add long options for dry run and quiet to be more consistent with the
rest of git.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Stephen Boyd authored and Junio C Hamano committed Jul 11, 2009
1 parent c9c3c67 commit 7cfe0c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Documentation/git-prune-packed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
29 changes: 12 additions & 17 deletions builtin-prune-packed.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}

0 comments on commit 7cfe0c9

Please sign in to comment.