@matheusbsbs / matheus-bagliano / commits / 7cfe0c9802
Fork 0

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 <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Jul 7, 2009 at 22:15 UTC 7cfe0c9802d6d6c915cba91b73a591622dbcbc93
2 files changed +15 -18
Documentation/git-prune-packed.txt
+3 -1
@@ -8,7 +8,7 @@ git-prune-packed - Remove extra objects that are already in pack files
8
9 SYNOPSIS
10 --------
11 -'git prune-packed' [-n] [-q]
11 +'git prune-packed' [-n|--dry-run] [-q|--quiet]
12
13
14 DESCRIPTION
@@ -28,10 +28,12 @@ disk storage, etc.
28 OPTIONS
29 -------
30 -n::
31 +--dry-run::
32 Don't actually remove any objects, only show those that would have been
33 removed.
34
35 -q::
36 +--quiet::
37 Squelch the progress indicator.
38
39 Author
builtin-prune-packed.c
+12 -17
@@ -1,9 +1,12 @@
1 #include "builtin.h"
2 #include "cache.h"
3 #include "progress.h"
4 +#include "parse-options.h"
5
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 +};
10
11 #define DRY_RUN 01
12 #define VERBOSE 02
@@ -68,24 +71,16 @@ void prune_packed_objects(int opts)
71
72 int cmd_prune_packed(int argc, const char **argv, const char *prefix)
73 {
71 - int i;
74 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 + };
80
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);
83
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 - }
84 prune_packed_objects(opts);
85 return 0;
86 }