]> git.ipfire.org Git - thirdparty/git.git/commitdiff
read-tree: add --quiet
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 22 Mar 2019 09:31:37 +0000 (16:31 +0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 24 Mar 2019 12:35:34 +0000 (21:35 +0900)
read-tree is basically the front end of unpack-trees code and shoud
expose all of its functionality (unless it's designed for internal
use). This "opts.quiet" (formerly "opts.gently") was added for
builtin/checkout.c but there is no reason why other read-tree users
won't find this useful.

The test that is updated to run 'read-tree --quiet' was added because
unpack-trees was accidentally not being quiet [1] in 6a143aa2b2
(checkout -m: attempt merge when deletion of path was staged -
2014-08-12). Because checkout is the only "opts.quiet" user, there was
no other way to test quiet behavior. But we can now test it directly.

6a143aa2b2 was manually reverted to verify that read-tree --quiet
works correctly (i.e. test_must_be_empty fails).

[1] the commit message there say "errors out instead of performing a
    merge" but I'm pretty sure the "performing a merge" happens anyway
    even before that commit. That line should say "errors out
    _in addition to_ performing a merge"

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-read-tree.txt
builtin/read-tree.c
t/t7201-co.sh

index 5c70bc2878fc2f68698b931c6bf951d0097ef813..1e81f9c4e6deec2f719098ebad351bc3c073c6cc 100644 (file)
@@ -128,6 +128,10 @@ OPTIONS
        Instead of reading tree object(s) into the index, just empty
        it.
 
+-q::
+--quiet::
+       Quiet, suppress feedback messages.
+
 <tree-ish#>::
        The id of the tree object(s) to be read/merged.
 
index 9083dcfa28a38f7f804c1fdcaa56fb4260b4e6f0..5c9c0825957532dc5e59668889adaf15708007ac 100644 (file)
@@ -154,6 +154,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
                { OPTION_CALLBACK, 0, "recurse-submodules", NULL,
                            "checkout", "control recursive updating of submodules",
                            PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater },
+               OPT__QUIET(&opts.quiet, N_("suppress feedback messages")),
                OPT_END()
        };
 
index 72b9b375baa6b26d0bca91c0c2d214cd4a9b8a42..f1655820194278fb36ee7c7a73a83f869d040589 100755 (executable)
@@ -223,6 +223,9 @@ test_expect_success 'switch to another branch while carrying a deletion' '
        test_must_fail git checkout simple 2>errs &&
        test_i18ngrep overwritten errs &&
 
+       test_must_fail git read-tree --quiet -m -u HEAD simple 2>errs &&
+       test_must_be_empty errs &&
+
        git checkout --merge simple 2>errs &&
        test_i18ngrep ! overwritten errs &&
        git ls-files -u &&