X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-prune-packed.c;h=f9463deec2f5a5875ee9870e67c990a2fea942db;hb=cab1b013e6f7cc52806926a792c6798f4c7ac4be;hp=00590b1c3c2cceda7a75537c8680a96cd2ef84d4;hpb=011c181cc656c8b3e48882729d1b6238e8c5c537;p=git.git diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c index 00590b1c3..f9463deec 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; + int opts = isatty(2) ? VERBOSE : 0; + 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; }