git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] gc: fix regression in 7b0f229222 impacting --quiet
@ 2018-09-19 21:01 Ævar Arnfjörð Bjarmason
  2018-09-19 21:21 ` Martin Ågren
  0 siblings, 1 reply; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-09-19 21:01 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Duy Nguyen,
	Ævar Arnfjörð Bjarmason

Fix a regression in my recent 7b0f229222 ("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 perquisite 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 <avarab@gmail.com>
---
 builtin/gc.c  |  2 +-
 t/t6500-gc.sh | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index 06ddd3aea5..91ffb1a803 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -647,7 +647,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 
 	if (gc_write_commit_graph)
 		write_commit_graph_reachable(get_object_directory(), 0,
-					     !daemonized);
+					     !quiet && !daemonized);
 
 	if (auto_gc && too_many_loose_objects())
 		warning(_("There are too many unreachable loose objects; "
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index 818435f04e..6183702c30 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -4,6 +4,7 @@ test_description='basic git gc tests
 '
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
 
 test_expect_success 'setup' '
 	# 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
 	test_line_count = 2 new # There is one new pack and its .idx
 '
 
+test_expect_success 'gc --no-quiet' '
+	git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
+	! test -s stdout &&
+	test_line_count = 1 stderr &&
+	test_i18ngrep "Computing commit graph generation numbers" stderr
+'
+
+test_expect_success TTY 'with TTY: gc --no-quiet' '
+	test_terminal git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
+	! test -s stdout &&
+	test_i18ngrep "Enumerating objects" stderr &&
+	test_i18ngrep "Computing commit graph generation numbers" stderr
+'
+
+test_expect_success 'gc --quiet' '
+	git -c gc.writeCommitGraph=true gc --quiet >stdout 2>stderr &&
+	! test -s stdout &&
+	! test -s stderr
+'
+
 run_and_wait_for_auto_gc () {
 	# We read stdout from gc for the side effect of waiting until the
 	# background gc process exits, closing its fd 9.  Furthermore, the
-- 
2.19.0.444.g18242da7ef


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gc: fix regression in 7b0f229222 impacting --quiet
  2018-09-19 21:01 [PATCH] gc: fix regression in 7b0f229222 impacting --quiet Ævar Arnfjörð Bjarmason
@ 2018-09-19 21:21 ` Martin Ågren
  2018-09-19 23:22   ` Derrick Stolee
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Ågren @ 2018-09-19 21:21 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Git Mailing List, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

On Wed, 19 Sep 2018 at 23:04, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> Fix a regression in my recent 7b0f229222 ("commit-graph write: add
> progress output", 2018-09-17), the newly added progress output for
> "commit-graph write" didn't check the --quiet option.

s/, t/. T/, perhaps. Maybe also s/did/does/.

> Do so, and add a test asserting that this works as expected. Since the
> TTY perquisite isn't available everywhere let's add a version of this

s/perq/prereq/

> 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).

> +test_expect_success 'gc --no-quiet' '
> +       git -c gc.writeCommitGraph=true gc --no-quiet >stdout 2>stderr &&
> +       ! test -s stdout &&

`test_must_be_empty` for easier debugging?

> +       test_line_count = 1 stderr &&
> +       test_i18ngrep "Computing commit graph generation numbers" stderr
> +'

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gc: fix regression in 7b0f229222 impacting --quiet
  2018-09-19 21:21 ` Martin Ågren
@ 2018-09-19 23:22   ` Derrick Stolee
  0 siblings, 0 replies; 3+ messages in thread
From: Derrick Stolee @ 2018-09-19 23:22 UTC (permalink / raw)
  To: Martin Ågren, Ævar Arnfjörð Bjarmason
  Cc: Git Mailing List, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

On 9/19/2018 5:21 PM, Martin Ågren wrote:
> On Wed, 19 Sep 2018 at 23:04, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>> Fix a regression in my recent 7b0f229222 ("commit-graph write: add
>> progress output", 2018-09-17), the newly added progress output for
>> "commit-graph write" didn't check the --quiet option.
Thanks for fixing this issue. Sorry I missed it in review.

I looked through the patch and didn't find anything more than Martin 
already did. I appreciate the tests.

Thanks,
-Stolee


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-20 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19 21:01 [PATCH] gc: fix regression in 7b0f229222 impacting --quiet Ævar Arnfjörð Bjarmason
2018-09-19 21:21 ` Martin Ågren
2018-09-19 23:22   ` Derrick Stolee

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).