]>
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[] = { | |
680cba2c | 9 | N_("git multi-pack-index [<options>] (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; |
680cba2c | 16 | int progress; |
6a257f03 DS |
17 | } opts; |
18 | ||
19 | int cmd_multi_pack_index(int argc, const char **argv, | |
20 | const char *prefix) | |
21 | { | |
680cba2c WB |
22 | unsigned flags = 0; |
23 | ||
6a257f03 DS |
24 | static struct option builtin_multi_pack_index_options[] = { |
25 | OPT_FILENAME(0, "object-dir", &opts.object_dir, | |
26 | N_("object directory containing set of packfile and pack-index pairs")), | |
680cba2c | 27 | OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")), |
2af890bb DS |
28 | OPT_MAGNITUDE(0, "batch-size", &opts.batch_size, |
29 | N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")), | |
6a257f03 DS |
30 | OPT_END(), |
31 | }; | |
32 | ||
33 | git_config(git_default_config, NULL); | |
34 | ||
680cba2c | 35 | opts.progress = isatty(2); |
6a257f03 DS |
36 | argc = parse_options(argc, argv, prefix, |
37 | builtin_multi_pack_index_options, | |
38 | builtin_multi_pack_index_usage, 0); | |
39 | ||
40 | if (!opts.object_dir) | |
41 | opts.object_dir = get_object_directory(); | |
680cba2c WB |
42 | if (opts.progress) |
43 | flags |= MIDX_PROGRESS; | |
6a257f03 | 44 | |
a3407730 | 45 | if (argc == 0) |
6d68e6a4 DS |
46 | usage_with_options(builtin_multi_pack_index_usage, |
47 | builtin_multi_pack_index_options); | |
a3407730 | 48 | |
6d68e6a4 DS |
49 | if (argc > 1) { |
50 | die(_("too many arguments")); | |
51 | return 1; | |
52 | } | |
a3407730 | 53 | |
d829223a JH |
54 | trace2_cmd_mode(argv[0]); |
55 | ||
2af890bb | 56 | if (!strcmp(argv[0], "repack")) |
680cba2c WB |
57 | return midx_repack(the_repository, opts.object_dir, |
58 | (size_t)opts.batch_size, flags); | |
2af890bb DS |
59 | if (opts.batch_size) |
60 | die(_("--batch-size option is only for 'repack' subcommand")); | |
61 | ||
6d68e6a4 | 62 | if (!strcmp(argv[0], "write")) |
680cba2c | 63 | return write_midx_file(opts.object_dir, flags); |
56ee7ff1 | 64 | if (!strcmp(argv[0], "verify")) |
680cba2c | 65 | return verify_midx_file(the_repository, opts.object_dir, flags); |
cff97116 | 66 | if (!strcmp(argv[0], "expire")) |
680cba2c | 67 | return expire_midx_packs(the_repository, opts.object_dir, flags); |
a3407730 | 68 | |
2af890bb | 69 | die(_("unrecognized subcommand: %s"), argv[0]); |
6a257f03 | 70 | } |