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>
Taylor Blau committed
Sep 20, 2021 at 17:39 UTC
0394f8d0025b83922735b1d46cfd4e446916c8c3
3 files changed
+35
-14
Documentation/git-multi-pack-index.txt
+3
-3
@@ -9,8 +9,7 @@ git-multi-pack-index - Write and verify multi-pack-indexes
9
SYNOPSIS
10
--------
11
[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>
13
14
DESCRIPTION
15
-----------
@@ -26,7 +25,8 @@ OPTIONS
25
26
--[no-]progress::
27
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.
30
31
The following subcommands are available:
32
builtin/multi-pack-index.c
+26
-5
@@ -52,7 +52,6 @@ static struct opts_multi_pack_index {
52
static struct option common_opts[] = {
53
OPT_FILENAME(0, "object-dir", &opts.object_dir,
54
N_("object directory containing set of packfile and pack-index pairs")),
55
- OPT_BIT(0, "progress", &opts.flags, N_("force progress reporting"), MIDX_PROGRESS),
55
OPT_END(),
56
};
57
@@ -68,6 +67,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
67
OPT_STRING(0, "preferred-pack", &opts.preferred_pack,
68
N_("preferred-pack"),
69
N_("pack for reuse when computing a multi-pack bitmap")),
70
+ OPT_BIT(0, "progress", &opts.flags,
71
+ N_("force progress reporting"), MIDX_PROGRESS),
72
OPT_END(),
73
};
74
@@ -75,6 +76,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
76
77
trace2_cmd_mode(argv[0]);
78
79
+ if (isatty(2))
80
+ opts.flags |= MIDX_PROGRESS;
81
argc = parse_options(argc, argv, NULL,
82
options, builtin_multi_pack_index_write_usage,
83
PARSE_OPT_KEEP_UNKNOWN);
@@ -90,10 +93,18 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
93
94
static int cmd_multi_pack_index_verify(int argc, const char **argv)
95
{
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);
103
104
trace2_cmd_mode(argv[0]);
105
106
+ if (isatty(2))
107
+ opts.flags |= MIDX_PROGRESS;
108
argc = parse_options(argc, argv, NULL,
109
options, builtin_multi_pack_index_verify_usage,
110
PARSE_OPT_KEEP_UNKNOWN);
@@ -106,10 +117,18 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv)
117
118
static int cmd_multi_pack_index_expire(int argc, const char **argv)
119
{
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);
127
128
trace2_cmd_mode(argv[0]);
129
130
+ if (isatty(2))
131
+ opts.flags |= MIDX_PROGRESS;
132
argc = parse_options(argc, argv, NULL,
133
options, builtin_multi_pack_index_expire_usage,
134
PARSE_OPT_KEEP_UNKNOWN);
@@ -126,6 +145,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
145
static struct option builtin_multi_pack_index_repack_options[] = {
146
OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
147
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),
150
OPT_END(),
151
};
152
@@ -133,6 +154,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
154
155
trace2_cmd_mode(argv[0]);
156
157
+ if (isatty(2))
158
+ opts.flags |= MIDX_PROGRESS;
159
argc = parse_options(argc, argv, NULL,
160
options,
161
builtin_multi_pack_index_repack_usage,
@@ -154,8 +177,6 @@ int cmd_multi_pack_index(int argc, const char **argv,
177
178
git_config(git_default_config, NULL);
179
157
- if (isatty(2))
158
- opts.flags |= MIDX_PROGRESS;
180
argc = parse_options(argc, argv, prefix,
181
builtin_multi_pack_index_options,
182
builtin_multi_pack_index_usage,
t/t5319-multi-pack-index.sh
+6
-6
@@ -174,12 +174,12 @@ test_expect_success 'write progress off for redirected stderr' '
174
'
175
176
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 &&
178
test_file_not_empty err
179
'
180
181
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 &&
183
test_line_count = 0 err
184
'
185
@@ -429,12 +429,12 @@ test_expect_success 'repack progress off for redirected stderr' '
429
'
430
431
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 &&
433
test_file_not_empty err
434
'
435
436
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 &&
438
test_line_count = 0 err
439
'
440
@@ -618,7 +618,7 @@ test_expect_success 'expire progress off for redirected stderr' '
618
test_expect_success 'expire force progress on for stderr' '
619
(
620
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 &&
622
test_file_not_empty err
623
)
624
'
@@ -626,7 +626,7 @@ test_expect_success 'expire force progress on for stderr' '
626
test_expect_success 'expire with the --no-progress option' '
627
(
628
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 &&
630
test_line_count = 0 err
631
)
632
'