Skip to content

Commit a04cef9

Browse files
committed
Merge branch 'rs/bundle-parseopt-cleanup'
Code clean-up. * rs/bundle-parseopt-cleanup: bundle: use OPT_PASSTHRU_ARGV
2 parents e48d9c7 + d089a06 commit a04cef9

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
@@ -68,42 +68,36 @@ static int parse_options_cmd_bundle(int argc,
6868
}
6969

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

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

97-
strvec_init(&pack_opts);
98-
if (progress == 0)
99-
strvec_push(&pack_opts, "--quiet");
100-
else if (progress == 1)
101-
strvec_push(&pack_opts, "--progress");
102-
else if (progress == 2)
103-
strvec_push(&pack_opts, "--all-progress");
104-
if (progress && all_progress_implied)
105-
strvec_push(&pack_opts, "--all-progress-implied");
106-
107101
if (!startup_info->have_repository)
108102
die(_("Need a repository to create a bundle."));
109103
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)