submodule update: silence underlying fetch with "--quiet"

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>

Nicholas Clark committed Apr 30, 2021 at 09:59 UTC 62af4bdd423f5f3988dad97abcdd7adfba0756c4
2 files changed +26 -2
git-submodule.sh
+2 -2
@@ -420,9 +420,9 @@ fetch_in_submodule () (
420 cd "$1" &&
421 if test $# -eq 3
422 then
423 - echo "$3" | git fetch --stdin ${2:+"$2"}
423 + echo "$3" | git fetch ${GIT_QUIET:+--quiet} --stdin ${2:+"$2"}
424 else
425 - git fetch ${2:+"$2"}
425 + git fetch ${GIT_QUIET:+--quiet} ${2:+"$2"}
426 fi
427 )
428
t/t7406-submodule-update.sh
+24
@@ -1037,4 +1037,28 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'
1037 )
1038 '
1039
1040 +test_expect_success 'submodule update --quiet passes quietness to fetch with a shallow clone' '
1041 + test_when_finished "rm -rf super4 super5 super6" &&
1042 + git clone . super4 &&
1043 + (cd super4 &&
1044 + git submodule add --quiet file://"$TRASH_DIRECTORY"/submodule submodule3 &&
1045 + git commit -am "setup submodule3"
1046 + ) &&
1047 + (cd submodule &&
1048 + test_commit line6 file
1049 + ) &&
1050 + git clone super4 super5 &&
1051 + (cd super5 &&
1052 + git submodule update --quiet --init --depth=1 submodule3 >out 2>err &&
1053 + test_must_be_empty out &&
1054 + test_must_be_empty err
1055 + ) &&
1056 + git clone super4 super6 &&
1057 + (cd super6 &&
1058 + git submodule update --init --depth=1 submodule3 >out 2>err &&
1059 + test_file_not_empty out &&
1060 + test_file_not_empty err
1061 + )
1062 +'
1063 +
1064 test_done