Skip to content

Commit 844cc43

Browse files
committed
Merge branch 'tb/commit-graph-usage-fix'
Regression in "git commit-graph" command line parsing has been corrected. * tb/commit-graph-usage-fix: builtin/multi-pack-index.c: disable top-level --[no-]progress builtin/commit-graph.c: don't accept common --[no-]progress
2 parents 7cebe73 + 0394f8d commit 844cc43

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
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>] [--[no-]bitmap] <subcommand>
12+
'git multi-pack-index' [--object-dir=<dir>] [--[no-]bitmap] <sub-command>
1413

1514
DESCRIPTION
1615
-----------
@@ -28,7 +27,8 @@ OPTIONS
2827

2928
--[no-]progress::
3029
Turn progress on/off explicitly. If neither is specified, progress is
31-
shown if standard error is connected to a terminal.
30+
shown if standard error is connected to a terminal. Supported by
31+
sub-commands `write`, `verify`, `expire`, and `repack.
3232

3333
The following subcommands are available:
3434

builtin/commit-graph.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ static struct option common_opts[] = {
5050
OPT_STRING(0, "object-dir", &opts.obj_dir,
5151
N_("dir"),
5252
N_("the object directory to store the graph")),
53-
OPT_BOOL(0, "progress", &opts.progress,
54-
N_("force progress reporting")),
5553
OPT_END()
5654
};
5755

@@ -73,6 +71,8 @@ static int graph_verify(int argc, const char **argv)
7371
static struct option builtin_commit_graph_verify_options[] = {
7472
OPT_BOOL(0, "shallow", &opts.shallow,
7573
N_("if the commit-graph is split, only verify the tip file")),
74+
OPT_BOOL(0, "progress", &opts.progress,
75+
N_("force progress reporting")),
7676
OPT_END(),
7777
};
7878
struct option *options = add_common_options(builtin_commit_graph_verify_options);
@@ -224,6 +224,8 @@ static int graph_write(int argc, const char **argv)
224224
OPT_CALLBACK_F(0, "max-new-filters", &write_opts.max_new_filters,
225225
NULL, N_("maximum number of changed-path Bloom filters to compute"),
226226
0, write_option_max_new_filters),
227+
OPT_BOOL(0, "progress", &opts.progress,
228+
N_("force progress reporting")),
227229
OPT_END(),
228230
};
229231
struct option *options = add_common_options(builtin_commit_graph_write_options);

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

@@ -70,13 +69,17 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
7069
N_("pack for reuse when computing a multi-pack bitmap")),
7170
OPT_BIT(0, "bitmap", &opts.flags, N_("write multi-pack bitmap"),
7271
MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX),
72+
OPT_BIT(0, "progress", &opts.flags,
73+
N_("force progress reporting"), MIDX_PROGRESS),
7374
OPT_END(),
7475
};
7576

7677
options = add_common_options(builtin_multi_pack_index_write_options);
7778

7879
trace2_cmd_mode(argv[0]);
7980

81+
if (isatty(2))
82+
opts.flags |= MIDX_PROGRESS;
8083
argc = parse_options(argc, argv, NULL,
8184
options, builtin_multi_pack_index_write_usage,
8285
PARSE_OPT_KEEP_UNKNOWN);
@@ -92,10 +95,18 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
9295

9396
static int cmd_multi_pack_index_verify(int argc, const char **argv)
9497
{
95-
struct option *options = common_opts;
98+
struct option *options;
99+
static struct option builtin_multi_pack_index_verify_options[] = {
100+
OPT_BIT(0, "progress", &opts.flags,
101+
N_("force progress reporting"), MIDX_PROGRESS),
102+
OPT_END(),
103+
};
104+
options = add_common_options(builtin_multi_pack_index_verify_options);
96105

97106
trace2_cmd_mode(argv[0]);
98107

108+
if (isatty(2))
109+
opts.flags |= MIDX_PROGRESS;
99110
argc = parse_options(argc, argv, NULL,
100111
options, builtin_multi_pack_index_verify_usage,
101112
PARSE_OPT_KEEP_UNKNOWN);
@@ -108,10 +119,18 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv)
108119

109120
static int cmd_multi_pack_index_expire(int argc, const char **argv)
110121
{
111-
struct option *options = common_opts;
122+
struct option *options;
123+
static struct option builtin_multi_pack_index_expire_options[] = {
124+
OPT_BIT(0, "progress", &opts.flags,
125+
N_("force progress reporting"), MIDX_PROGRESS),
126+
OPT_END(),
127+
};
128+
options = add_common_options(builtin_multi_pack_index_expire_options);
112129

113130
trace2_cmd_mode(argv[0]);
114131

132+
if (isatty(2))
133+
opts.flags |= MIDX_PROGRESS;
115134
argc = parse_options(argc, argv, NULL,
116135
options, builtin_multi_pack_index_expire_usage,
117136
PARSE_OPT_KEEP_UNKNOWN);
@@ -128,13 +147,17 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
128147
static struct option builtin_multi_pack_index_repack_options[] = {
129148
OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
130149
N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
150+
OPT_BIT(0, "progress", &opts.flags,
151+
N_("force progress reporting"), MIDX_PROGRESS),
131152
OPT_END(),
132153
};
133154

134155
options = add_common_options(builtin_multi_pack_index_repack_options);
135156

136157
trace2_cmd_mode(argv[0]);
137158

159+
if (isatty(2))
160+
opts.flags |= MIDX_PROGRESS;
138161
argc = parse_options(argc, argv, NULL,
139162
options,
140163
builtin_multi_pack_index_repack_usage,
@@ -156,8 +179,6 @@ int cmd_multi_pack_index(int argc, const char **argv,
156179

157180
git_config(git_default_config, NULL);
158181

159-
if (isatty(2))
160-
opts.flags |= MIDX_PROGRESS;
161182
argc = parse_options(argc, argv, prefix,
162183
builtin_multi_pack_index_options,
163184
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

@@ -474,12 +474,12 @@ test_expect_success 'repack progress off for redirected stderr' '
474474
'
475475

476476
test_expect_success 'repack force progress on for stderr' '
477-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
477+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --progress 2>err &&
478478
test_file_not_empty err
479479
'
480480

481481
test_expect_success 'repack with the --no-progress option' '
482-
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
482+
GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --no-progress 2>err &&
483483
test_line_count = 0 err
484484
'
485485

@@ -672,15 +672,15 @@ test_expect_success 'expire progress off for redirected stderr' '
672672
test_expect_success 'expire force progress on for stderr' '
673673
(
674674
cd dup &&
675-
GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
675+
GIT_PROGRESS_DELAY=0 git multi-pack-index expire --progress 2>err &&
676676
test_file_not_empty err
677677
)
678678
'
679679

680680
test_expect_success 'expire with the --no-progress option' '
681681
(
682682
cd dup &&
683-
GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
683+
GIT_PROGRESS_DELAY=0 git multi-pack-index expire --no-progress 2>err &&
684684
test_line_count = 0 err
685685
)
686686
'

0 commit comments

Comments
 (0)