Skip to content

Commit d089a06

Browse files
rscharfegitster
authored andcommitted
bundle: use OPT_PASSTHRU_ARGV
"git bundle" passes the progress control options to "git pack-objects" by parsing and then recreating them explicitly. Simplify that process by using OPT_PASSTHRU_ARGV instead. This also fixes --no-quiet, which has been doing the same as --quiet since its introduction by 79862b6 (bundle-create: progress output control, 2019-11-10) because it had been defined using OPT_SET_INT with a value of 0, which sets 0 when negated as well. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb7d80e commit d089a06

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

builtin/bundle.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,42 +69,36 @@ static int parse_options_cmd_bundle(int argc,
6969
}
7070

7171
static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
72-
int all_progress_implied = 1;
73-
int progress = isatty(STDERR_FILENO);
74-
struct strvec pack_opts;
72+
struct strvec pack_opts = STRVEC_INIT;
7573
int version = -1;
7674
int ret;
7775
struct option options[] = {
78-
OPT_SET_INT('q', "quiet", &progress,
79-
N_("do not show progress meter"), 0),
80-
OPT_SET_INT(0, "progress", &progress,
81-
N_("show progress meter"), 1),
82-
OPT_SET_INT_F(0, "all-progress", &progress,
83-
N_("historical; same as --progress"), 2,
84-
PARSE_OPT_HIDDEN),
85-
OPT_HIDDEN_BOOL(0, "all-progress-implied",
86-
&all_progress_implied,
87-
N_("historical; does nothing")),
76+
OPT_PASSTHRU_ARGV('q', "quiet", &pack_opts, NULL,
77+
N_("do not show progress meter"),
78+
PARSE_OPT_NOARG),
79+
OPT_PASSTHRU_ARGV(0, "progress", &pack_opts, NULL,
80+
N_("show progress meter"),
81+
PARSE_OPT_NOARG),
82+
OPT_PASSTHRU_ARGV(0, "all-progress", &pack_opts, NULL,
83+
N_("historical; same as --progress"),
84+
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
85+
OPT_PASSTHRU_ARGV(0, "all-progress-implied", &pack_opts, NULL,
86+
N_("historical; does nothing"),
87+
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
8888
OPT_INTEGER(0, "version", &version,
8989
N_("specify bundle format version")),
9090
OPT_END()
9191
};
9292
char *bundle_file;
9393

94+
if (isatty(STDERR_FILENO))
95+
strvec_push(&pack_opts, "--progress");
96+
strvec_push(&pack_opts, "--all-progress-implied");
97+
9498
argc = parse_options_cmd_bundle(argc, argv, prefix,
9599
builtin_bundle_create_usage, options, &bundle_file);
96100
/* bundle internals use argv[1] as further parameters */
97101

98-
strvec_init(&pack_opts);
99-
if (progress == 0)
100-
strvec_push(&pack_opts, "--quiet");
101-
else if (progress == 1)
102-
strvec_push(&pack_opts, "--progress");
103-
else if (progress == 2)
104-
strvec_push(&pack_opts, "--all-progress");
105-
if (progress && all_progress_implied)
106-
strvec_push(&pack_opts, "--all-progress-implied");
107-
108102
if (!startup_info->have_repository)
109103
die(_("Need a repository to create a bundle."));
110104
ret = !!create_bundle(the_repository, bundle_file, argc, argv, &pack_opts, version);

t/t6020-bundle-misc.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,12 @@ test_expect_success TTY 'create --quiet disables all bundle progress' '
619619
test_must_be_empty err
620620
'
621621

622+
test_expect_success 'bundle progress with --no-quiet' '
623+
GIT_PROGRESS_DELAY=0 \
624+
git bundle create --no-quiet out.bundle --all 2>err &&
625+
grep "%" err
626+
'
627+
622628
test_expect_success 'read bundle over stdin' '
623629
git bundle create some.bundle HEAD &&
624630

0 commit comments

Comments
 (0)