Skip to content

Commit f7c4d63

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1187556 commit f7c4d63

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

builtin/multi-pack-index.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ static struct opts_multi_pack_index {
1414
const char *object_dir;
1515
unsigned long batch_size;
1616
int progress;
17+
unsigned flags;
1718
} opts;
1819

1920
int cmd_multi_pack_index(int argc, const char **argv,
2021
const char *prefix)
2122
{
22-
unsigned flags = 0;
23-
2423
static struct option builtin_multi_pack_index_options[] = {
2524
OPT_FILENAME(0, "object-dir", &opts.object_dir,
2625
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,
4039
if (!opts.object_dir)
4140
opts.object_dir = get_object_directory();
4241
if (opts.progress)
43-
flags |= MIDX_PROGRESS;
42+
opts.flags |= MIDX_PROGRESS;
4443

4544
if (argc == 0)
4645
usage_with_options(builtin_multi_pack_index_usage,
@@ -55,16 +54,16 @@ int cmd_multi_pack_index(int argc, const char **argv,
5554

5655
if (!strcmp(argv[0], "repack"))
5756
return midx_repack(the_repository, opts.object_dir,
58-
(size_t)opts.batch_size, flags);
57+
(size_t)opts.batch_size, opts.flags);
5958
if (opts.batch_size)
6059
die(_("--batch-size option is only for 'repack' subcommand"));
6160

6261
if (!strcmp(argv[0], "write"))
63-
return write_midx_file(opts.object_dir, flags);
62+
return write_midx_file(opts.object_dir, opts.flags);
6463
if (!strcmp(argv[0], "verify"))
65-
return verify_midx_file(the_repository, opts.object_dir, flags);
64+
return verify_midx_file(the_repository, opts.object_dir, opts.flags);
6665
if (!strcmp(argv[0], "expire"))
67-
return expire_midx_packs(the_repository, opts.object_dir, flags);
66+
return expire_midx_packs(the_repository, opts.object_dir, opts.flags);
6867

6968
die(_("unrecognized subcommand: %s"), argv[0]);
7069
}

0 commit comments

Comments
 (0)