Subject: [PATCH] submodule: update and add must honor --quiet flag

From: Jens Lehmann <[email-masked]>
Date: Tue, 26 Jul 2011 23:39:03 +0200

When using the --quiet flag "git submodule update" and "git submodule add"
didn't behave as the documentation stated. They printed progress output
from the clone, even though they should only print error messages.

Fix that by passing the -q flag to git clone in module_clone() when the
GIT_QUIET variable is set. Two tests in t7400 have been modified to test
that behavior.

Reported-by: Daniel Holtmann-Rice <[email-masked]>
Signed-off-by: Jens Lehmann <[email-masked]>
---

Am 26.07.2011 13:26, schrieb Daniel Holtmann-Rice:
> I can't find a place to submit bug reports, so I'll post this here...

This is the right place.

> the --quiet/-q flag seems to have no effect for 'git submodule update'.  For example (http://pastebin.com/0KWT4EeA):
> 
> #!/bin/bash
> 
> git clone -q git://github.com/dhr/evp-tools.git
> cd evp-tools
> git submodule -q init
> git submodule -q update
> 
> This doesn't run quietly (the first three commands do, the last does not).  I've tried this through Git 1.7.6.

Thanks for reporting this, this patch should fix it.

 git-submodule.sh           |    9 +++++++--
 t/t7400-submodule-basic.sh |    6 ++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index bc1d3fa..f46862f 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -122,12 +122,17 @@ module_clone()
 	path=$1
 	url=$2
 	reference="$3"
+	quiet=
+	if test -n "$GIT_QUIET"
+	then
+		quiet=-q
+	fi

 	if test -n "$reference"
 	then
-		git-clone "$reference" -n "$url" "$path"
+		git-clone $quiet "$reference" -n "$url" "$path"
 	else
-		git-clone -n "$url" "$path"
+		git-clone $quiet -n "$url" "$path"
 	fi ||
 	die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")"
 }
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 5afe6cc..bc70d69 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -75,7 +75,8 @@ test_expect_success 'submodule add' '

 	(
 		cd addtest &&
-		git submodule add "$submodurl" submod &&
+		git submodule add -q "$submodurl" submod >actual &&
+		test ! -s actual &&
 		git submodule init
 	) &&

@@ -273,7 +274,8 @@ test_expect_success 'update should work when path is an empty dir' '
 	echo "$rev1" >expect &&

 	mkdir init &&
-	git submodule update &&
+	git submodule update -q >update.out &&
+	test ! -s update.out &&

 	inspect init &&
 	test_cmp expect head-sha1
-- 
1.7.6.347.g4db0d.dirty