Skip to content

Commit 6b89a34

Browse files
avargitster
authored andcommitted
gc: fix regression in 7b0f229 impacting --quiet
Fix a regression in my recent 7b0f229 ("commit-graph write: add progress output", 2018-09-17). The newly added progress output for "commit-graph write" didn't check the --quiet option. Do so, and add a test asserting that this works as expected. Since the TTY prequisite isn't available everywhere let's add a version of this that both requires and doesn't require that. This test might be overly specific and will break if new progress output is added, but I think it'll serve as a good reminder to test the undertested progress mode(s). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Helped-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1f7f557 commit 6b89a34

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

builtin/gc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
647647

648648
if (gc_write_commit_graph)
649649
write_commit_graph_reachable(get_object_directory(), 0,
650-
!daemonized);
650+
!quiet && !daemonized);
651651

652652
if (auto_gc && too_many_loose_objects())
653653
warning(_("There are too many unreachable loose objects; "

t/t6500-gc.sh

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='basic git gc tests
44
'
55

66
. ./test-lib.sh
7+
. "$TEST_DIRECTORY"/lib-terminal.sh
78

89
test_expect_success 'setup' '
910
# do not let the amount of physical memory affects gc
@@ -99,6 +100,26 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
99100
test_line_count = 2 new # There is one new pack and its .idx
100101
'
101102

103+
test_expect_success 'gc --no-quiet' '
104+
git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
105+
test_must_be_empty stdout &&
106+
test_line_count = 1 stderr &&
107+
test_i18ngrep "Computing commit graph generation numbers" stderr
108+
'
109+
110+
test_expect_success TTY 'with TTY: gc --no-quiet' '
111+
test_terminal git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
112+
test_must_be_empty stdout &&
113+
test_i18ngrep "Enumerating objects" stderr &&
114+
test_i18ngrep "Computing commit graph generation numbers" stderr
115+
'
116+
117+
test_expect_success 'gc --quiet' '
118+
git -c gc.writeCommitGraph=true gc --quiet >stdout 2>stderr &&
119+
test_must_be_empty stdout &&
120+
test_must_be_empty stderr
121+
'
122+
102123
run_and_wait_for_auto_gc () {
103124
# We read stdout from gc for the side effect of waiting until the
104125
# background gc process exits, closing its fd 9. Furthermore, the

0 commit comments

Comments
 (0)