path: root/builtin
diff options
authorTaylor Blau <>2021-03-30 15:03:47 (GMT)
committerJunio C Hamano <>2021-03-30 19:16:56 (GMT)
commitf7c4d63e35b4358f93efc8d2f124056c246f912e (patch)
treeac29d4935dc8d1b20b379521b7280327f9136bdb /builtin
parent11875561bf29cadc91fe43b7383ae05e4ab112b5 (diff)
builtin/multi-pack-index.c: inline 'flags' with options
Subcommands of the 'git multi-pack-index' command (e.g., 'write', 'verify', etc.) will want to optionally change a set of shared flags that are eventually passed to the MIDX libraries. Right now, options and flags are handled separately. That's fine, since the options structure is never passed around. But a future patch will make it so that common options shared by all sub-commands are defined in a common location. That means that "flags" would have to become a global variable. Group it with the options structure so that we reduce the number of global variables we have overall. Signed-off-by: Taylor Blau <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin')
1 files changed, 6 insertions, 7 deletions
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 5bf88cd..4a0ddb0 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -14,13 +14,12 @@ static struct opts_multi_pack_index {
const char *object_dir;
unsigned long batch_size;
int progress;
+ unsigned flags;
} opts;
int cmd_multi_pack_index(int argc, const char **argv,
const char *prefix)
- unsigned flags = 0;
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")),
@@ -40,7 +39,7 @@ int cmd_multi_pack_index(int argc, const char **argv,
if (!opts.object_dir)
opts.object_dir = get_object_directory();
if (opts.progress)
- flags |= MIDX_PROGRESS;
+ opts.flags |= MIDX_PROGRESS;
if (argc == 0)
@@ -55,16 +54,16 @@ int cmd_multi_pack_index(int argc, const char **argv,
if (!strcmp(argv[0], "repack"))
return midx_repack(the_repository, opts.object_dir,
- (size_t)opts.batch_size, flags);
+ (size_t)opts.batch_size, opts.flags);
if (opts.batch_size)
die(_("--batch-size option is only for 'repack' subcommand"));
if (!strcmp(argv[0], "write"))
- return write_midx_file(opts.object_dir, flags);
+ return write_midx_file(opts.object_dir, opts.flags);
if (!strcmp(argv[0], "verify"))
- return verify_midx_file(the_repository, opts.object_dir, flags);
+ return verify_midx_file(the_repository, opts.object_dir, opts.flags);
if (!strcmp(argv[0], "expire"))
- return expire_midx_packs(the_repository, opts.object_dir, flags);
+ return expire_midx_packs(the_repository, opts.object_dir, opts.flags);
die(_("unrecognized subcommand: %s"), argv[0]);