Skip to content

Commit c9c3c67

Browse files
bebarinogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4855b2a commit c9c3c67

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

Documentation/git-verify-pack.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-verify-pack - Validate packed git archive files
88

99
SYNOPSIS
1010
--------
11-
'git verify-pack' [-v] [--] <pack>.idx ...
11+
'git verify-pack' [-v|--verbose] [--] <pack>.idx ...
1212

1313

1414
DESCRIPTION
@@ -23,6 +23,7 @@ OPTIONS
2323
The idx files to verify.
2424

2525
-v::
26+
--verbose::
2627
After verifying the pack, show list of objects contained
2728
in the pack.
2829
\--::

builtin-verify-pack.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cache.h"
33
#include "pack.h"
44
#include "pack-revindex.h"
5+
#include "parse-options.h"
56

67
#define MAX_CHAIN 50
78

@@ -107,36 +108,31 @@ static int verify_one_pack(const char *path, int verbose)
107108
return err;
108109
}
109110

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+
};
111115

112116
int cmd_verify_pack(int argc, const char **argv, const char *prefix)
113117
{
114118
int err = 0;
115119
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+
};
118125

119126
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();
136135
}
137136

138-
if (nothing_done)
139-
usage(verify_pack_usage);
140-
141137
return err;
142138
}

0 commit comments

Comments
 (0)