diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2019-11-10 12:41:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-11-11 11:46:28 +0900 |
commit | 79862b6b77c07b88ae1137fa602bf2046f979ad9 (patch) | |
tree | 5083a781f623851f03527d277e844ed110d41150 /builtin | |
parent | bundle: framework for options before bundle file (diff) | |
download | tgif-79862b6b77c07b88ae1137fa602bf2046f979ad9.tar.xz |
bundle-create: progress output control
Support the progress output options from pack-objects in git-bundle's
create subcommand. Most notably, this provides --quiet as requested on
the git mailing list per [1]
Reference: https://www.mail-archive.com/git@vger.kernel.org/msg182844.html <robbat2-20190806T191156-796782357Z@orbis-terrarum.net>
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/bundle.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/builtin/bundle.c b/builtin/bundle.c index 09b989cfc0..39b3e88d40 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "argv-array.h" #include "parse-options.h" #include "cache.h" #include "bundle.h" @@ -11,7 +12,7 @@ */ static const char * const builtin_bundle_usage[] = { - N_("git bundle create <file> <git-rev-list args>"), + N_("git bundle create [<options>] <file> <git-rev-list args>"), N_("git bundle verify <file>"), N_("git bundle list-heads <file> [<refname>...]"), N_("git bundle unbundle <file> [<refname>...]"), @@ -19,7 +20,7 @@ static const char * const builtin_bundle_usage[] = { }; static const char * const builtin_bundle_create_usage[] = { - N_("git bundle create <file> <git-rev-list args>"), + N_("git bundle create [<options>] <file> <git-rev-list args>"), NULL }; @@ -56,7 +57,20 @@ static int parse_options_cmd_bundle(int argc, } static int cmd_bundle_create(int argc, const char **argv, const char *prefix) { + int all_progress_implied = 0; + int progress = isatty(STDERR_FILENO); + struct argv_array pack_opts; + struct option options[] = { + OPT_SET_INT('q', "quiet", &progress, + N_("do not show progress meter"), 0), + OPT_SET_INT(0, "progress", &progress, + N_("show progress meter"), 1), + OPT_SET_INT(0, "all-progress", &progress, + N_("show progress meter during object writing phase"), 2), + OPT_BOOL(0, "all-progress-implied", + &all_progress_implied, + N_("similar to --all-progress when progress meter is shown")), OPT_END() }; const char* bundle_file; @@ -65,9 +79,19 @@ static int cmd_bundle_create(int argc, const char **argv, const char *prefix) { builtin_bundle_create_usage, options, &bundle_file); /* bundle internals use argv[1] as further parameters */ + argv_array_init(&pack_opts); + if (progress == 0) + argv_array_push(&pack_opts, "--quiet"); + else if (progress == 1) + argv_array_push(&pack_opts, "--progress"); + else if (progress == 2) + argv_array_push(&pack_opts, "--all-progress"); + if (progress && all_progress_implied) + argv_array_push(&pack_opts, "--all-progress-implied"); + if (!startup_info->have_repository) die(_("Need a repository to create a bundle.")); - return !!create_bundle(the_repository, bundle_file, argc, argv); + return !!create_bundle(the_repository, bundle_file, argc, argv, &pack_opts); } static int cmd_bundle_verify(int argc, const char **argv, const char *prefix) { |