Merge branch 'ab/test-lib-pass-trace2-env'
[git/raj.git] / builtin / multi-pack-index.c
blobae6e476ad567e57e5a1e308d7901b0a0c331640f
1 #include "builtin.h"
2 #include "cache.h"
3 #include "config.h"
4 #include "parse-options.h"
5 #include "midx.h"
6 #include "trace2.h"
8 static char const * const builtin_multi_pack_index_usage[] = {
9 N_("git multi-pack-index [--object-dir=<dir>] (write|verify)"),
10 NULL
13 static struct opts_multi_pack_index {
14 const char *object_dir;
15 } opts;
17 int cmd_multi_pack_index(int argc, const char **argv,
18 const char *prefix)
20 static struct option builtin_multi_pack_index_options[] = {
21 OPT_FILENAME(0, "object-dir", &opts.object_dir,
22 N_("object directory containing set of packfile and pack-index pairs")),
23 OPT_END(),
26 git_config(git_default_config, NULL);
28 argc = parse_options(argc, argv, prefix,
29 builtin_multi_pack_index_options,
30 builtin_multi_pack_index_usage, 0);
32 if (!opts.object_dir)
33 opts.object_dir = get_object_directory();
35 if (argc == 0)
36 usage_with_options(builtin_multi_pack_index_usage,
37 builtin_multi_pack_index_options);
39 if (argc > 1) {
40 die(_("too many arguments"));
41 return 1;
44 trace2_cmd_mode(argv[0]);
46 if (!strcmp(argv[0], "write"))
47 return write_midx_file(opts.object_dir);
48 if (!strcmp(argv[0], "verify"))
49 return verify_midx_file(opts.object_dir);
51 die(_("unrecognized verb: %s"), argv[0]);