Skip to content

Commit 0394f8d

Browse files
ttaylorrgitster
authored andcommitted
builtin/multi-pack-index.c: disable top-level --[no-]progress
In a similar spirit as the previous patch, let sub-commands which support showing or hiding a progress meter handle parsing the `--progress` or `--no-progress` option, but do not expose it as an option to the top-level `multi-pack-index` builtin. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d5fdf30 commit 0394f8d

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

Documentation/git-multi-pack-index.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ git-multi-pack-index - Write and verify multi-pack-indexes
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git multi-pack-index' [--object-dir=<dir>] [--[no-]progress]
13-
[--preferred-pack=<pack>] <subcommand>
12+
'git multi-pack-index' [--object-dir=<dir>] <sub-command>
1413

1514
DESCRIPTION
1615
-----------
@@ -26,7 +25,8 @@ OPTIONS
2625

2726
--[no-]progress::
2827
Turn progress on/off explicitly. If neither is specified, progress is
29-
shown if standard error is connected to a terminal.
28+
shown if standard error is connected to a terminal. Supported by
29+
sub-commands `write`, `verify`, `expire`, and `repack.
3030

3131
The following subcommands are available:
3232

builtin/multi-pack-index.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ static struct opts_multi_pack_index {
5252
static struct option common_opts[] = {
5353
OPT_FILENAME(0, "object-dir", &opts.object_dir,
5454
N_("object directory containing set of packfile and pack-index pairs")),
55-
OPT_BIT(0, "progress", &opts.flags, N_("force progress reporting"), MIDX_PROGRESS),
5655
OPT_END(),
5756
};
5857

@@ -68,13 +67,17 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
6867
OPT_STRING(0, "preferred-pack", &opts.preferred_pack,
6968
N_("preferred-pack"),
7069
N_("pack for reuse when computing a multi-pack bitmap")),
70+
OPT_BIT(0, "progress", &opts.flags,
71+
N_("force progress reporting"), MIDX_PROGRESS),
7172
OPT_END(),
7273
};
7374

7475
options = add_common_options(builtin_multi_pack_index_write_options);
7576

7677
trace2_cmd_mode(argv[0]);
7778

79+
if (isatty(2))
80+
opts.flags |= MIDX_PROGRESS;
7881
argc = parse_options(argc, argv, NULL,
7982
options, builtin_multi_pack_index_write_usage,
8083
PARSE_OPT_KEEP_UNKNOWN);
@@ -90,10 +93,18 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
9093

9194
static int cmd_multi_pack_index_verify(int argc, const char **argv)
9295
{
93-
struct option *options = common_opts;
96+
struct option *options;
97+
static struct option builtin_multi_pack_index_verify_options[] = {
98+
OPT_BIT(0, "progress", &opts.flags,
99+
N_("force progress reporting"), MIDX_PROGRESS),
100+
OPT_END(),
101+
};
102+
options = add_common_options(builtin_multi_pack_index_verify_options);
94103

95104
trace2_cmd_mode(argv[0]);
96105

106+
if (isatty(2))
107+
opts.flags |= MIDX_PROGRESS;
97108
argc = parse_options(argc, argv, NULL,
98109
options, builtin_multi_pack_index_verify_usage,
99110
PARSE_OPT_KEEP_UNKNOWN);
@@ -106,10 +117,18 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv)
106117

107118
static int cmd_multi_pack_index_expire(int argc, const char **argv)
108119
{
109-
struct option *options = common_opts;
120+
struct option *options;
121+
static struct option builtin_multi_pack_index_expire_options[] = {
122+
OPT_BIT(0, "progress", &opts.flags,
123+
N_("force progress reporting"), MIDX_PROGRESS),
124+
OPT_END(),
125+
};
126+
options = add_common_options(builtin_multi_pack_index_expire_options);
110127

111128
trace2_cmd_mode(argv[0]);
112129

130+
if (isatty(2))
131+
opts.flags |= MIDX_PROGRESS;
113132
argc = parse_options(argc, argv, NULL,
114133
options, builtin_multi_pack_index_expire_usage,
115134
PARSE_OPT_KEEP_UNKNOWN);
@@ -126,13 +145,17 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
126145
static struct option builtin_multi_pack_index_repack_options[] = {
127146
OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
128147
N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
148+
OPT_BIT(0, "progress", &opts.flags,
149+
N_("force progress reporting"), MIDX_PROGRESS),
129150
OPT_END(),
130151
};
131152

132153
options = add_common_options(builtin_multi_pack_index_repack_options);
133154

134155
trace2_cmd_mode(argv[0]);
135156

157+
if (isatty(2))
158+
opts.flags |= MIDX_PROGRESS;
136159
argc = parse_options(argc, argv, NULL,
137160
options,
138161
builtin_multi_pack_index_repack_usage,
@@ -154,8 +177,6 @@ int cmd_multi_pack_index(int argc, const char **argv,
154177

155178
git_config(git_default_config, NULL);
156179

157-
if (isatty(2))
158-
opts.flags |= MIDX_PROGRESS;
159180
argc = parse_options(argc, argv, prefix,
160181
builtin_multi_pack_index_options,
161182
builtin_multi_pack_index_usage,

t/t5319-multi-pack-index.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ test_expect_success 'write progress off for redirected stderr' '
174174
'
175175

176176
test_expect_success 'write force progress on for stderr' '
177-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress write 2>err &&
177+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir write --progress 2>err &&
178178
test_file_not_empty err
179179
'
180180

181181
test_expect_success 'write with the --no-progress option' '
182-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
182+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir write --no-progress 2>err &&
183183
test_line_count = 0 err
184184
'
185185

@@ -429,12 +429,12 @@ test_expect_success 'repack progress off for redirected stderr' '
429429
'
430430

431431
test_expect_success 'repack force progress on for stderr' '
432-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
432+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --progress 2>err &&
433433
test_file_not_empty err
434434
'
435435

436436
test_expect_success 'repack with the --no-progress option' '
437-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
437+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --no-progress 2>err &&
438438
test_line_count = 0 err
439439
'
440440

@@ -618,15 +618,15 @@ test_expect_success 'expire progress off for redirected stderr' '
618618
test_expect_success 'expire force progress on for stderr' '
619619
(
620620
cd dup &&
621-
GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
621+
GIT_PROGRESS_DELAY=0 git multi-pack-index expire --progress 2>err &&
622622
test_file_not_empty err
623623
)
624624
'
625625

626626
test_expect_success 'expire with the --no-progress option' '
627627
(
628628
cd dup &&
629-
GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
629+
GIT_PROGRESS_DELAY=0 git multi-pack-index expire --no-progress 2>err &&
630630
test_line_count = 0 err
631631
)
632632
'

0 commit comments

Comments
 (0)