test-lib-functions: suppress a 'git rev-parse' error in 'test_commit_bulk'
diff mbox series

Message ID 20191125125907.28967-1-szeder.dev@gmail.com
State New
Headers show
Series
  • test-lib-functions: suppress a 'git rev-parse' error in 'test_commit_bulk'
Related show

Commit Message

SZEDER Gábor Nov. 25, 2019, 12:59 p.m. UTC
When 'test_commit_bulk' is invoked in an empty test repository, it
prints a "fatal: Needed a single revision" error, but still does what
it's supposed to do.  A test helper function displaying a fatal error
and still succeeding is always suspect to be buggy, but luckily that's
not the case here: that error comes from a 'git rev-parse --verify
HEAD' command invoked in a condition, which doesn't have anything to
verify in an empty repository.

Use the '--quiet' option to suppress that error message.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/test-lib-functions.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff King Nov. 25, 2019, 1:19 p.m. UTC | #1
On Mon, Nov 25, 2019 at 01:59:07PM +0100, SZEDER Gábor wrote:

> When 'test_commit_bulk' is invoked in an empty test repository, it
> prints a "fatal: Needed a single revision" error, but still does what
> it's supposed to do.  A test helper function displaying a fatal error
> and still succeeding is always suspect to be buggy, but luckily that's
> not the case here: that error comes from a 'git rev-parse --verify
> HEAD' command invoked in a condition, which doesn't have anything to
> verify in an empty repository.
> 
> Use the '--quiet' option to suppress that error message.

Yep, makes perfect sense. Thanks.

-Peff

Patch
diff mbox series

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b299ecc326..6302bfb51d 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -308,7 +308,7 @@  test_commit_bulk () {
 	total=$1
 
 	add_from=
-	if git -C "$indir" rev-parse --verify "$ref"
+	if git -C "$indir" rev-parse --quiet --verify "$ref"
 	then
 		add_from=t
 	fi