2018-07-13 03:39:20 +08:00
|
|
|
#include "builtin.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "parse-options.h"
|
2018-07-13 03:39:21 +08:00
|
|
|
#include "midx.h"
|
2019-03-22 03:36:13 +08:00
|
|
|
#include "trace2.h"
|
2018-07-13 03:39:20 +08:00
|
|
|
|
|
|
|
static char const * const builtin_multi_pack_index_usage[] = {
|
2019-10-22 02:40:03 +08:00
|
|
|
N_("git multi-pack-index [<options>] (write|verify|expire|repack --batch-size=<size>)"),
|
2018-07-13 03:39:20 +08:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct opts_multi_pack_index {
|
|
|
|
const char *object_dir;
|
2019-06-11 07:35:26 +08:00
|
|
|
unsigned long batch_size;
|
2019-10-22 02:40:03 +08:00
|
|
|
int progress;
|
2018-07-13 03:39:20 +08:00
|
|
|
} opts;
|
|
|
|
|
|
|
|
int cmd_multi_pack_index(int argc, const char **argv,
|
|
|
|
const char *prefix)
|
|
|
|
{
|
2019-10-22 02:40:03 +08:00
|
|
|
unsigned flags = 0;
|
|
|
|
|
2018-07-13 03:39:20 +08:00
|
|
|
static struct option builtin_multi_pack_index_options[] = {
|
|
|
|
OPT_FILENAME(0, "object-dir", &opts.object_dir,
|
|
|
|
N_("object directory containing set of packfile and pack-index pairs")),
|
2019-10-22 02:40:03 +08:00
|
|
|
OPT_BOOL(0, "progress", &opts.progress, N_("force progress reporting")),
|
2019-06-11 07:35:26 +08:00
|
|
|
OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
|
|
|
|
N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
|
2018-07-13 03:39:20 +08:00
|
|
|
OPT_END(),
|
|
|
|
};
|
|
|
|
|
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
|
2019-10-22 02:40:03 +08:00
|
|
|
opts.progress = isatty(2);
|
2018-07-13 03:39:20 +08:00
|
|
|
argc = parse_options(argc, argv, prefix,
|
|
|
|
builtin_multi_pack_index_options,
|
|
|
|
builtin_multi_pack_index_usage, 0);
|
|
|
|
|
|
|
|
if (!opts.object_dir)
|
|
|
|
opts.object_dir = get_object_directory();
|
2019-10-22 02:40:03 +08:00
|
|
|
if (opts.progress)
|
|
|
|
flags |= MIDX_PROGRESS;
|
2018-07-13 03:39:20 +08:00
|
|
|
|
2018-07-13 03:39:21 +08:00
|
|
|
if (argc == 0)
|
2018-08-21 00:51:53 +08:00
|
|
|
usage_with_options(builtin_multi_pack_index_usage,
|
|
|
|
builtin_multi_pack_index_options);
|
2018-07-13 03:39:21 +08:00
|
|
|
|
2018-08-21 00:51:53 +08:00
|
|
|
if (argc > 1) {
|
|
|
|
die(_("too many arguments"));
|
|
|
|
return 1;
|
|
|
|
}
|
2018-07-13 03:39:21 +08:00
|
|
|
|
2019-03-22 03:36:13 +08:00
|
|
|
trace2_cmd_mode(argv[0]);
|
|
|
|
|
2019-06-11 07:35:26 +08:00
|
|
|
if (!strcmp(argv[0], "repack"))
|
2019-10-22 02:40:03 +08:00
|
|
|
return midx_repack(the_repository, opts.object_dir,
|
|
|
|
(size_t)opts.batch_size, flags);
|
2019-06-11 07:35:26 +08:00
|
|
|
if (opts.batch_size)
|
|
|
|
die(_("--batch-size option is only for 'repack' subcommand"));
|
|
|
|
|
2018-08-21 00:51:53 +08:00
|
|
|
if (!strcmp(argv[0], "write"))
|
2019-10-22 02:40:03 +08:00
|
|
|
return write_midx_file(opts.object_dir, flags);
|
2018-09-14 02:02:13 +08:00
|
|
|
if (!strcmp(argv[0], "verify"))
|
2019-10-22 02:40:03 +08:00
|
|
|
return verify_midx_file(the_repository, opts.object_dir, flags);
|
2019-06-11 07:35:23 +08:00
|
|
|
if (!strcmp(argv[0], "expire"))
|
2019-10-22 02:40:03 +08:00
|
|
|
return expire_midx_packs(the_repository, opts.object_dir, flags);
|
2018-07-13 03:39:21 +08:00
|
|
|
|
2019-06-11 07:35:26 +08:00
|
|
|
die(_("unrecognized subcommand: %s"), argv[0]);
|
2018-07-13 03:39:20 +08:00
|
|
|
}
|