]> git.ipfire.org Git - thirdparty/git.git/blob - builtin/multi-pack-index.c
Merge branch 'vv/merge-squash-with-explicit-commit' into maint
[thirdparty/git.git] / builtin / multi-pack-index.c
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"
7
8 static char const * const builtin_multi_pack_index_usage[] = {
9 N_("git multi-pack-index [--object-dir=<dir>] (write|verify)"),
10 NULL
11 };
12
13 static struct opts_multi_pack_index {
14 const char *object_dir;
15 } opts;
16
17 int cmd_multi_pack_index(int argc, const char **argv,
18 const char *prefix)
19 {
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(),
24 };
25
26 git_config(git_default_config, NULL);
27
28 argc = parse_options(argc, argv, prefix,
29 builtin_multi_pack_index_options,
30 builtin_multi_pack_index_usage, 0);
31
32 if (!opts.object_dir)
33 opts.object_dir = get_object_directory();
34
35 if (argc == 0)
36 usage_with_options(builtin_multi_pack_index_usage,
37 builtin_multi_pack_index_options);
38
39 if (argc > 1) {
40 die(_("too many arguments"));
41 return 1;
42 }
43
44 trace2_cmd_mode(argv[0]);
45
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(the_repository, opts.object_dir);
50
51 die(_("unrecognized verb: %s"), argv[0]);
52 }