Commit 612392ee9a232ecb6f4f9db91eafbe6693509bd9

Stefan Sperling 2021-01-05T14:01:16

allow the 'got fetch' -l option together with the -q option Make use of this in tests to hide useless output from ssh(1).

diff --git a/got/got.1 b/got/got.1
index 84e6393..8560ea5 100644
--- a/got/got.1
+++ b/got/got.1
@@ -391,7 +391,8 @@ Git's garbage collector.
 List branches and tags available for fetching from the remote repository
 and exit immediately.
 Cannot be used together with any of the other options except
-.Fl v
+.Fl v ,
+.Fl q ,
 and
 .Fl r .
 .It Fl t
diff --git a/got/got.c b/got/got.c
index 1a0fbb7..dc1e82d 100644
--- a/got/got.c
+++ b/got/got.c
@@ -2087,8 +2087,6 @@ cmd_fetch(int argc, char *argv[])
 			option_conflict('l', 'a');
 		if (delete_refs)
 			option_conflict('l', 'd');
-		if (verbosity == -1)
-			option_conflict('l', 'q');
 	}
 
 	if (argc == 0)
diff --git a/regress/cmdline/fetch.sh b/regress/cmdline/fetch.sh
index 1fc5c95..06f040f 100755
--- a/regress/cmdline/fetch.sh
+++ b/regress/cmdline/fetch.sh
@@ -136,7 +136,7 @@ test_fetch_list() {
 		return 1
 	fi
 
-	(cd $testroot/repo-clone && got fetch -l \
+	(cd $testroot/repo-clone && got fetch -q -l \
 		> $testroot/stdout 2>$testroot/stderr)
 	ret="$?"
 	if [ "$ret" != "0" ]; then
@@ -145,8 +145,7 @@ test_fetch_list() {
 		return 1
 	fi
 
-	echo "Connecting to \"origin\" 127.0.0.1" > $testroot/stdout.expected
-	got ref -l -r $testroot/repo >> $testroot/stdout.expected
+	got ref -l -r $testroot/repo > $testroot/stdout.expected
 
 	cmp -s $testroot/stdout $testroot/stdout.expected
 	ret="$?"
@@ -999,7 +998,7 @@ remote "barbaz" {
 EOF
 	echo "got: nonexistent: remote repository not found" \
 		> $testroot/stderr.expected
-	(cd $testroot/repo-clone && got fetch nonexistent \
+	(cd $testroot/repo-clone && got fetch -q nonexistent \
 		> $testroot/stdout 2> $testroot/stderr)
 	ret="$?"
 	if [ "$ret" = "0" ]; then
@@ -1009,7 +1008,7 @@ EOF
 		return 1
 	fi
 
-	(cd $testroot/repo-clone && got fetch -l foobar \
+	(cd $testroot/repo-clone && got fetch -q -l foobar \
 		> $testroot/stdout)
 	ret="$?"
 	if [ "$ret" != "0" ]; then
@@ -1018,8 +1017,7 @@ EOF
 		return 1
 	fi
 
-	echo "Connecting to \"foobar\" 127.0.0.1" > $testroot/stdout.expected
-	got ref -l -r $testroot/repo >> $testroot/stdout.expected
+	got ref -l -r $testroot/repo > $testroot/stdout.expected
 
 	cmp -s $testroot/stdout $testroot/stdout.expected
 	ret="$?"
@@ -1038,7 +1036,7 @@ remote "barbaz" {
 	repository "$testroot/repo"
 }
 EOF
-	(cd $testroot/wt && got fetch -l barbaz > $testroot/stdout)
+	(cd $testroot/wt && got fetch -q -l barbaz > $testroot/stdout)
 	ret="$?"
 	if [ "$ret" != "0" ]; then
 		echo "got fetch command failed unexpectedly" >&2
@@ -1046,8 +1044,7 @@ EOF
 		return 1
 	fi
 
-	echo "Connecting to \"barbaz\" 127.0.0.1" > $testroot/stdout.expected
-	got ref -l -r $testroot/repo >> $testroot/stdout.expected
+	got ref -l -r $testroot/repo > $testroot/stdout.expected
 
 	cmp -s $testroot/stdout $testroot/stdout.expected
 	ret="$?"