]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/multi-pack-index.c: disable top-level --[no-]progress
authorTaylor Blau <me@ttaylorr.com>
Mon, 20 Sep 2021 21:39:19 +0000 (17:39 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Sep 2021 16:26:29 +0000 (09:26 -0700)
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>
Documentation/git-multi-pack-index.txt
builtin/multi-pack-index.c
t/t5319-multi-pack-index.sh

index ffd601bc17b4dc8f453e6a5b28fb4d6239176d96..5ba4bd516625aa6e24016a54b748fcb18ece9360 100644 (file)
@@ -9,8 +9,7 @@ git-multi-pack-index - Write and verify multi-pack-indexes
 SYNOPSIS
 --------
 [verse]
-'git multi-pack-index' [--object-dir=<dir>] [--[no-]progress]
-       [--preferred-pack=<pack>] <subcommand>
+'git multi-pack-index' [--object-dir=<dir>] <sub-command>
 
 DESCRIPTION
 -----------
@@ -26,7 +25,8 @@ OPTIONS
 
 --[no-]progress::
        Turn progress on/off explicitly. If neither is specified, progress is
-       shown if standard error is connected to a terminal.
+       shown if standard error is connected to a terminal. Supported by
+       sub-commands `write`, `verify`, `expire`, and `repack.
 
 The following subcommands are available:
 
index 649aa5f9ab2d214e7486f3fbb80a1d9254ec1edd..5f11a3067da392379fc52afaebbe72f81f8ccf01 100644 (file)
@@ -52,7 +52,6 @@ static struct opts_multi_pack_index {
 static struct option common_opts[] = {
        OPT_FILENAME(0, "object-dir", &opts.object_dir,
          N_("object directory containing set of packfile and pack-index pairs")),
-       OPT_BIT(0, "progress", &opts.flags, N_("force progress reporting"), MIDX_PROGRESS),
        OPT_END(),
 };
 
@@ -68,6 +67,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
                OPT_STRING(0, "preferred-pack", &opts.preferred_pack,
                           N_("preferred-pack"),
                           N_("pack for reuse when computing a multi-pack bitmap")),
+               OPT_BIT(0, "progress", &opts.flags,
+                       N_("force progress reporting"), MIDX_PROGRESS),
                OPT_END(),
        };
 
@@ -75,6 +76,8 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
 
        trace2_cmd_mode(argv[0]);
 
+       if (isatty(2))
+               opts.flags |= MIDX_PROGRESS;
        argc = parse_options(argc, argv, NULL,
                             options, builtin_multi_pack_index_write_usage,
                             PARSE_OPT_KEEP_UNKNOWN);
@@ -90,10 +93,18 @@ static int cmd_multi_pack_index_write(int argc, const char **argv)
 
 static int cmd_multi_pack_index_verify(int argc, const char **argv)
 {
-       struct option *options = common_opts;
+       struct option *options;
+       static struct option builtin_multi_pack_index_verify_options[] = {
+               OPT_BIT(0, "progress", &opts.flags,
+                       N_("force progress reporting"), MIDX_PROGRESS),
+               OPT_END(),
+       };
+       options = add_common_options(builtin_multi_pack_index_verify_options);
 
        trace2_cmd_mode(argv[0]);
 
+       if (isatty(2))
+               opts.flags |= MIDX_PROGRESS;
        argc = parse_options(argc, argv, NULL,
                             options, builtin_multi_pack_index_verify_usage,
                             PARSE_OPT_KEEP_UNKNOWN);
@@ -106,10 +117,18 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv)
 
 static int cmd_multi_pack_index_expire(int argc, const char **argv)
 {
-       struct option *options = common_opts;
+       struct option *options;
+       static struct option builtin_multi_pack_index_expire_options[] = {
+               OPT_BIT(0, "progress", &opts.flags,
+                       N_("force progress reporting"), MIDX_PROGRESS),
+               OPT_END(),
+       };
+       options = add_common_options(builtin_multi_pack_index_expire_options);
 
        trace2_cmd_mode(argv[0]);
 
+       if (isatty(2))
+               opts.flags |= MIDX_PROGRESS;
        argc = parse_options(argc, argv, NULL,
                             options, builtin_multi_pack_index_expire_usage,
                             PARSE_OPT_KEEP_UNKNOWN);
@@ -126,6 +145,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
        static struct option builtin_multi_pack_index_repack_options[] = {
                OPT_MAGNITUDE(0, "batch-size", &opts.batch_size,
                  N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
+               OPT_BIT(0, "progress", &opts.flags,
+                 N_("force progress reporting"), MIDX_PROGRESS),
                OPT_END(),
        };
 
@@ -133,6 +154,8 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv)
 
        trace2_cmd_mode(argv[0]);
 
+       if (isatty(2))
+               opts.flags |= MIDX_PROGRESS;
        argc = parse_options(argc, argv, NULL,
                             options,
                             builtin_multi_pack_index_repack_usage,
@@ -154,8 +177,6 @@ int cmd_multi_pack_index(int argc, const char **argv,
 
        git_config(git_default_config, NULL);
 
-       if (isatty(2))
-               opts.flags |= MIDX_PROGRESS;
        argc = parse_options(argc, argv, prefix,
                             builtin_multi_pack_index_options,
                             builtin_multi_pack_index_usage,
index 3d4d9f10c31b2ff1a0c5bb21458a3ef54113802f..86b7de2281885b98f1e6af33cfad5dcbb6292f55 100755 (executable)
@@ -174,12 +174,12 @@ test_expect_success 'write progress off for redirected stderr' '
 '
 
 test_expect_success 'write force progress on for stderr' '
-       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress write 2>err &&
+       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir write --progress 2>err &&
        test_file_not_empty err
 '
 
 test_expect_success 'write with the --no-progress option' '
-       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress write 2>err &&
+       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir write --no-progress 2>err &&
        test_line_count = 0 err
 '
 
@@ -429,12 +429,12 @@ test_expect_success 'repack progress off for redirected stderr' '
 '
 
 test_expect_success 'repack force progress on for stderr' '
-       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --progress repack 2>err &&
+       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --progress 2>err &&
        test_file_not_empty err
 '
 
 test_expect_success 'repack with the --no-progress option' '
-       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir --no-progress repack 2>err &&
+       GIT_PROGRESS_DELAY=0 git multi-pack-index --object-dir=$objdir repack --no-progress 2>err &&
        test_line_count = 0 err
 '
 
@@ -618,7 +618,7 @@ test_expect_success 'expire progress off for redirected stderr' '
 test_expect_success 'expire force progress on for stderr' '
        (
                cd dup &&
-               GIT_PROGRESS_DELAY=0 git multi-pack-index --progress expire 2>err &&
+               GIT_PROGRESS_DELAY=0 git multi-pack-index expire --progress 2>err &&
                test_file_not_empty err
        )
 '
@@ -626,7 +626,7 @@ test_expect_success 'expire force progress on for stderr' '
 test_expect_success 'expire with the --no-progress option' '
        (
                cd dup &&
-               GIT_PROGRESS_DELAY=0 git multi-pack-index --no-progress expire 2>err &&
+               GIT_PROGRESS_DELAY=0 git multi-pack-index expire --no-progress 2>err &&
                test_line_count = 0 err
        )
 '