{"thread":{"id":"55593","subject":"[PATCH] submodule update: silence underlying fetch with \"--quiet\"","startedAt":"2021-04-30T10:27:42Z","lastAt":"2021-04-30T10:27:42Z","messageCount":1,"participants":["Nicholas Clark"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"423333","messageId":"20210430095906.GG9170@etla.org","threadId":"55593","inReplyTo":null,"subject":"[PATCH] submodule update: silence underlying fetch with \"--quiet\"","fromName":"Nicholas Clark","fromEmail":"nick@ccl4.org","sentAt":"2021-04-30T09:59:06Z","receivedAt":"2021-04-30T10:27:42Z","isPatch":true,"sender":{"key":"nick@ccl4.org","avatar":null},"body":"Commands such as\n\n    $ git submodule update --quiet --init --depth=1\n\ninvolving shallow clones, call the shell function fetch_in_submodule, which\nin turn invokes git fetch.  Pass the --quiet option onward there.\n\nSigned-off-by: Nicholas Clark <nick@ccl4.org>\n---\nI tried to adopt the same approach as the previous commit that fixed a\n--quiet bug, 3ad0401e9e (submodule update: silence underlying merge/rebase\nwith \"--quiet\", 2020-09-30)\n\nI believe that the bugfix is correct but I struggled to create a concise\nregression test demonstrates the bug and the bug fix.\n\nThat commit is not the only fix of a --quiet bug, so I'm wondering if there\nare others still to find. I looked in git-submodule.sh and see many\ninvocations of git commands in git-submodule.sh, most of which don't pass\n${GIT_QUIET:+--quiet} onward, but I don't know git well enough to know which\nmight matter (ie might generate output), and it feels like cargo-cult to\nadd that code unthinkingly to every git command, so I didn't do this.\n\n git-submodule.sh            |  4 ++--\n t/t7406-submodule-update.sh | 24 ++++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex eb90f18229..4678378424 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -420,9 +420,9 @@ fetch_in_submodule () (\n \tcd \"$1\" &&\n \tif test $# -eq 3\n \tthen\n-\t\techo \"$3\" | git fetch --stdin ${2:+\"$2\"}\n+\t\techo \"$3\" | git fetch ${GIT_QUIET:+--quiet} --stdin ${2:+\"$2\"}\n \telse\n-\t\tgit fetch ${2:+\"$2\"}\n+\t\tgit fetch ${GIT_QUIET:+--quiet} ${2:+\"$2\"}\n \tfi\n )\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex ff3ba5422e..f4f61fe554 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -1037,4 +1037,28 @@ test_expect_success 'submodule update --quiet passes quietness to merge/rebase'\n \t)\n '\n \n+test_expect_success 'submodule update --quiet passes quietness to fetch with a shallow clone' '\n+\ttest_when_finished \"rm -rf super4 super5 super6\" &&\n+\tgit clone . super4 &&\n+\t(cd super4 &&\n+\t git submodule add --quiet file://\"$TRASH_DIRECTORY\"/submodule submodule3 &&\n+\t git commit -am \"setup submodule3\"\n+\t) &&\n+\t(cd submodule &&\n+\t  test_commit line6 file\n+\t) &&\n+\tgit clone super4 super5 &&\n+\t(cd super5 &&\n+\t git submodule update --quiet --init --depth=1 submodule3 >out 2>err &&\n+\t test_must_be_empty out &&\n+\t test_must_be_empty err\n+\t) &&\n+\tgit clone super4 super6 &&\n+\t(cd super6 &&\n+\t git submodule update --init --depth=1 submodule3 >out 2>err &&\n+\t test_file_not_empty out &&\n+\t test_file_not_empty err\n+\t)\n+'\n+\n test_done\n-- \n2.31.1\n\n"}]}