@matheusbsbs / matheus-bagliano / commits / c9c3c6781c
Fork 0

verify-pack: migrate to parse-options

OPT__VERBOSE introduces the long option (--verbose) in addition to the already present short option (-v), so document this new addition. 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 c9c3c6781c5b97c37b3ce16af7ea9bc613413c7e
2 files changed +20 -23
Documentation/git-verify-pack.txt
+2 -1
@@ -8,7 +8,7 @@ git-verify-pack - Validate packed git archive files
8
9 SYNOPSIS
10 --------
11 -'git verify-pack' [-v] [--] <pack>.idx ...
11 +'git verify-pack' [-v|--verbose] [--] <pack>.idx ...
12
13
14 DESCRIPTION
@@ -23,6 +23,7 @@ OPTIONS
23 The idx files to verify.
24
25 -v::
26 +--verbose::
27 After verifying the pack, show list of objects contained
28 in the pack.
29 \--::
builtin-verify-pack.c
+18 -22
@@ -2,6 +2,7 @@
2 #include "cache.h"
3 #include "pack.h"
4 #include "pack-revindex.h"
5 +#include "parse-options.h"
6
7 #define MAX_CHAIN 50
8
@@ -107,36 +108,31 @@ static int verify_one_pack(const char *path, int verbose)
108 return err;
109 }
110
110 -static const char verify_pack_usage[] = "git verify-pack [-v] <pack>...";
111 +static const char * const verify_pack_usage[] = {
112 + "git verify-pack [-v|--verbose] <pack>...",
113 + NULL
114 +};
115
116 int cmd_verify_pack(int argc, const char **argv, const char *prefix)
117 {
118 int err = 0;
119 int verbose = 0;
116 - int no_more_options = 0;
117 - int nothing_done = 1;
120 + int i;
121 + const struct option verify_pack_options[] = {
122 + OPT__VERBOSE(&verbose),
123 + OPT_END()
124 + };
125
126 git_config(git_default_config, NULL);
120 - while (1 < argc) {
121 - if (!no_more_options && argv[1][0] == '-') {
122 - if (!strcmp("-v", argv[1]))
123 - verbose = 1;
124 - else if (!strcmp("--", argv[1]))
125 - no_more_options = 1;
126 - else
127 - usage(verify_pack_usage);
128 - }
129 - else {
130 - if (verify_one_pack(argv[1], verbose))
131 - err = 1;
132 - discard_revindex();
133 - nothing_done = 0;
134 - }
135 - argc--; argv++;
127 + argc = parse_options(argc, argv, prefix, verify_pack_options,
128 + verify_pack_usage, 0);
129 + if (argc < 1)
130 + usage_with_options(verify_pack_usage, verify_pack_options);
131 + for (i = 0; i < argc; i++) {
132 + if (verify_one_pack(argv[i], verbose))
133 + err = 1;
134 + discard_revindex();
135 }
136
138 - if (nothing_done)
139 - usage(verify_pack_usage);
140 -
137 return err;
138 }