multi-pack-index: add 'write' verb
[git/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
7 static char const * const builtin_multi_pack_index_usage[] = {
8 N_("git multi-pack-index [--object-dir=<dir>] write"),
9 NULL
10 };
11
12 static struct opts_multi_pack_index {
13 const char *object_dir;
14 } opts;
15
16 int cmd_multi_pack_index(int argc, const char **argv,
17 const char *prefix)
18 {
19 static struct option builtin_multi_pack_index_options[] = {
20 OPT_FILENAME(0, "object-dir", &opts.object_dir,
21 N_("object directory containing set of packfile and pack-index pairs")),
22 OPT_END(),
23 };
24
25 git_config(git_default_config, NULL);
26
27 argc = parse_options(argc, argv, prefix,
28 builtin_multi_pack_index_options,
29 builtin_multi_pack_index_usage, 0);
30
31 if (!opts.object_dir)
32 opts.object_dir = get_object_directory();
33
34 if (argc == 0)
35 goto usage;
36
37 if (!strcmp(argv[0], "write")) {
38 if (argc > 1)
39 goto usage;
40
41 return write_midx_file(opts.object_dir);
42 }
43
44 usage:
45 usage_with_options(builtin_multi_pack_index_usage,
46 builtin_multi_pack_index_options);
47 }