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>
This commit is contained in:
parent
4855b2a220
commit
c9c3c6781c
@ -8,7 +8,7 @@ git-verify-pack - Validate packed git archive files
|
|||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
'git verify-pack' [-v] [--] <pack>.idx ...
|
'git verify-pack' [-v|--verbose] [--] <pack>.idx ...
|
||||||
|
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
@ -23,6 +23,7 @@ OPTIONS
|
|||||||
The idx files to verify.
|
The idx files to verify.
|
||||||
|
|
||||||
-v::
|
-v::
|
||||||
|
--verbose::
|
||||||
After verifying the pack, show list of objects contained
|
After verifying the pack, show list of objects contained
|
||||||
in the pack.
|
in the pack.
|
||||||
\--::
|
\--::
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
#include "pack-revindex.h"
|
#include "pack-revindex.h"
|
||||||
|
#include "parse-options.h"
|
||||||
|
|
||||||
#define MAX_CHAIN 50
|
#define MAX_CHAIN 50
|
||||||
|
|
||||||
@ -107,36 +108,31 @@ static int verify_one_pack(const char *path, int verbose)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char verify_pack_usage[] = "git verify-pack [-v] <pack>...";
|
static const char * const verify_pack_usage[] = {
|
||||||
|
"git verify-pack [-v|--verbose] <pack>...",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
int cmd_verify_pack(int argc, const char **argv, const char *prefix)
|
int cmd_verify_pack(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
int no_more_options = 0;
|
int i;
|
||||||
int nothing_done = 1;
|
const struct option verify_pack_options[] = {
|
||||||
|
OPT__VERBOSE(&verbose),
|
||||||
|
OPT_END()
|
||||||
|
};
|
||||||
|
|
||||||
git_config(git_default_config, NULL);
|
git_config(git_default_config, NULL);
|
||||||
while (1 < argc) {
|
argc = parse_options(argc, argv, prefix, verify_pack_options,
|
||||||
if (!no_more_options && argv[1][0] == '-') {
|
verify_pack_usage, 0);
|
||||||
if (!strcmp("-v", argv[1]))
|
if (argc < 1)
|
||||||
verbose = 1;
|
usage_with_options(verify_pack_usage, verify_pack_options);
|
||||||
else if (!strcmp("--", argv[1]))
|
for (i = 0; i < argc; i++) {
|
||||||
no_more_options = 1;
|
if (verify_one_pack(argv[i], verbose))
|
||||||
else
|
|
||||||
usage(verify_pack_usage);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (verify_one_pack(argv[1], verbose))
|
|
||||||
err = 1;
|
err = 1;
|
||||||
discard_revindex();
|
discard_revindex();
|
||||||
nothing_done = 0;
|
|
||||||
}
|
}
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nothing_done)
|
|
||||||
usage(verify_pack_usage);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user