Skip to content

Commit 7cfe0c9

Browse files
bebarinogitster
authored andcommitted
prune-packed: migrate to parse-options
Add long options for dry run and quiet to be more consistent with the rest of git. Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c9c3c67 commit 7cfe0c9

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Documentation/git-prune-packed.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-prune-packed - Remove extra objects that are already in pack files
88

99
SYNOPSIS
1010
--------
11-
'git prune-packed' [-n] [-q]
11+
'git prune-packed' [-n|--dry-run] [-q|--quiet]
1212

1313

1414
DESCRIPTION
@@ -28,10 +28,12 @@ disk storage, etc.
2828
OPTIONS
2929
-------
3030
-n::
31+
--dry-run::
3132
Don't actually remove any objects, only show those that would have been
3233
removed.
3334

3435
-q::
36+
--quiet::
3537
Squelch the progress indicator.
3638

3739
Author

builtin-prune-packed.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include "builtin.h"
22
#include "cache.h"
33
#include "progress.h"
4+
#include "parse-options.h"
45

5-
static const char prune_packed_usage[] =
6-
"git prune-packed [-n] [-q]";
6+
static const char * const prune_packed_usage[] = {
7+
"git prune-packed [-n|--dry-run] [-q|--quiet]",
8+
NULL
9+
};
710

811
#define DRY_RUN 01
912
#define VERBOSE 02
@@ -68,24 +71,16 @@ void prune_packed_objects(int opts)
6871

6972
int cmd_prune_packed(int argc, const char **argv, const char *prefix)
7073
{
71-
int i;
7274
int opts = VERBOSE;
75+
const struct option prune_packed_options[] = {
76+
OPT_BIT('n', "dry-run", &opts, "dry run", DRY_RUN),
77+
OPT_NEGBIT('q', "quiet", &opts, "be quiet", VERBOSE),
78+
OPT_END()
79+
};
7380

74-
for (i = 1; i < argc; i++) {
75-
const char *arg = argv[i];
81+
argc = parse_options(argc, argv, prefix, prune_packed_options,
82+
prune_packed_usage, 0);
7683

77-
if (*arg == '-') {
78-
if (!strcmp(arg, "-n"))
79-
opts |= DRY_RUN;
80-
else if (!strcmp(arg, "-q"))
81-
opts &= ~VERBOSE;
82-
else
83-
usage(prune_packed_usage);
84-
continue;
85-
}
86-
/* Handle arguments here .. */
87-
usage(prune_packed_usage);
88-
}
8984
prune_packed_objects(opts);
9085
return 0;
9186
}

0 commit comments

Comments
 (0)