]>
Commit | Line | Data |
---|---|---|
6a257f03 DS |
1 | #include "builtin.h" |
2 | #include "cache.h" | |
3 | #include "config.h" | |
4 | #include "parse-options.h" | |
a3407730 | 5 | #include "midx.h" |
d829223a | 6 | #include "trace2.h" |
6a257f03 DS |
7 | |
8 | static char const * const builtin_multi_pack_index_usage[] = { | |
2af890bb | 9 | N_("git multi-pack-index [--object-dir=<dir>] (write|verify|expire|repack --batch-size=<size>)"), |
6a257f03 DS |
10 | NULL |
11 | }; | |
12 | ||
13 | static struct opts_multi_pack_index { | |
14 | const char *object_dir; | |
2af890bb | 15 | unsigned long batch_size; |
6a257f03 DS |
16 | } opts; |
17 | ||
18 | int cmd_multi_pack_index(int argc, const char **argv, | |
19 | const char *prefix) | |
20 | { | |
21 | static struct option builtin_multi_pack_index_options[] = { | |
22 | OPT_FILENAME(0, "object-dir", &opts.object_dir, | |
23 | N_("object directory containing set of packfile and pack-index pairs")), | |
2af890bb DS |
24 | OPT_MAGNITUDE(0, "batch-size", &opts.batch_size, |
25 | N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")), | |
6a257f03 DS |
26 | OPT_END(), |
27 | }; | |
28 | ||
29 | git_config(git_default_config, NULL); | |
30 | ||
31 | argc = parse_options(argc, argv, prefix, | |
32 | builtin_multi_pack_index_options, | |
33 | builtin_multi_pack_index_usage, 0); | |
34 | ||
35 | if (!opts.object_dir) | |
36 | opts.object_dir = get_object_directory(); | |
37 | ||
a3407730 | 38 | if (argc == 0) |
6d68e6a4 DS |
39 | usage_with_options(builtin_multi_pack_index_usage, |
40 | builtin_multi_pack_index_options); | |
a3407730 | 41 | |
6d68e6a4 DS |
42 | if (argc > 1) { |
43 | die(_("too many arguments")); | |
44 | return 1; | |
45 | } | |
a3407730 | 46 | |
d829223a JH |
47 | trace2_cmd_mode(argv[0]); |
48 | ||
2af890bb DS |
49 | if (!strcmp(argv[0], "repack")) |
50 | return midx_repack(the_repository, opts.object_dir, (size_t)opts.batch_size); | |
51 | if (opts.batch_size) | |
52 | die(_("--batch-size option is only for 'repack' subcommand")); | |
53 | ||
6d68e6a4 | 54 | if (!strcmp(argv[0], "write")) |
a3407730 | 55 | return write_midx_file(opts.object_dir); |
56ee7ff1 | 56 | if (!strcmp(argv[0], "verify")) |
64404a24 | 57 | return verify_midx_file(the_repository, opts.object_dir); |
cff97116 DS |
58 | if (!strcmp(argv[0], "expire")) |
59 | return expire_midx_packs(the_repository, opts.object_dir); | |
a3407730 | 60 | |
2af890bb | 61 | die(_("unrecognized subcommand: %s"), argv[0]); |
6a257f03 | 62 | } |