]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule update: silence underlying fetch with "--quiet"
authorNicholas Clark <nick@ccl4.org>
Fri, 30 Apr 2021 09:59:06 +0000 (09:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 May 2021 03:24:38 +0000 (12:24 +0900)
Commands such as

    $ git submodule update --quiet --init --depth=1

involving shallow clones, call the shell function fetch_in_submodule, which
in turn invokes git fetch.  Pass the --quiet option onward there.

Signed-off-by: Nicholas Clark <nick@ccl4.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh
t/t7406-submodule-update.sh

index eb90f182296c0127b45ecd2aca20aff96e24bddb..467837842406688b423088415fa1df5bfa9a1270 100755 (executable)
@@ -420,9 +420,9 @@ fetch_in_submodule () (
        cd "$1" &&
        if test $# -eq 3
        then
-               echo "$3" | git fetch --stdin ${2:+"$2"}
+               echo "$3" | git fetch ${GIT_QUIET:+--quiet} --stdin ${2:+"$2"}
        else
-               git fetch ${2:+"$2"}
+               git fetch ${GIT_QUIET:+--quiet} ${2:+"$2"}
        fi
 )
 
index ff3ba5422e9bdae64795eaa4fa617187f0b65725..f4f61fe5544cdb9e7cebc9a61625e6d9d1954ecb 100755 (executable)
@@ -1037,4 +1037,28 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'
        )
 '
 
+test_expect_success 'submodule update --quiet passes quietness to fetch with a shallow clone' '
+       test_when_finished "rm -rf super4 super5 super6" &&
+       git clone . super4 &&
+       (cd super4 &&
+        git submodule add --quiet file://"$TRASH_DIRECTORY"/submodule submodule3 &&
+        git commit -am "setup submodule3"
+       ) &&
+       (cd submodule &&
+         test_commit line6 file
+       ) &&
+       git clone super4 super5 &&
+       (cd super5 &&
+        git submodule update --quiet --init --depth=1 submodule3 >out 2>err &&
+        test_must_be_empty out &&
+        test_must_be_empty err
+       ) &&
+       git clone super4 super6 &&
+       (cd super6 &&
+        git submodule update --init --depth=1 submodule3 >out 2>err &&
+        test_file_not_empty out &&
+        test_file_not_empty err
+       )
+'
+
 test_done