{"thread":{"id":"47651","subject":"regression in output of git-pull --rebase --recurse-submodules=yes --quiet","startedAt":"2018-01-20T06:05:51Z","lastAt":"2019-04-16T07:48:59Z","messageCount":12,"participants":["Robin H. Johnson","Stefan Beller","Junio C Hamano","Duy Nguyen","Nguyễn Thái Ngọc Duy","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"336968","messageId":"robbat2-20180120T054223-685328376Z@orbis-terrarum.net","threadId":"47651","inReplyTo":null,"subject":"regression in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2018-01-20T05:57:29Z","receivedAt":"2018-01-20T06:05:51Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"Somewhere between 2.13.6 & 2.14.1 there's an output regression. I\nhaven't done a bisect to trace it down further yet.\n\nSpecifically, --rebase --recurse-submodules=yes seems to cause --quiet\nto not be effective anymore.\n\nFull commandline:\n$ git pull --rebase --recurse-submodules --quiet\n\nIn 2.13.6, there is no output, it's quiet as expect.\n\nIn 2.14.1, you get:\nHEAD is up to date.\nSubmodule path '_data/news': rebased into 'a50b763c338161b4621d23e9fa5cd6e11455d6ca'\nHEAD is up to date.\nSubmodule path 'glep': rebased into 'e1f100ec3ba44ab1672d61cabf4690b355e46158'\n\nSteps to reproduction:\n1. git clone --recurse-submodules \\\n https://anongit.gentoo.org/git/sites/www.git\n2. cd www\n3. git submodule foreach --quiet git pull --quiet origin master\n4. git pull --rebase --recurse-submodules=yes --quiet\n\nRepeat step 4 for repeated bug output.\nIf you drop the --rebase, then you need to re-run step 3 first.\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Dev, Infra Lead, Foundation Treasurer\nE-Mail   : robbat2@gentoo.org\nGnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\nGnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n"},{"id":"337395","messageId":"20180125190817.145041-1-sbeller@google.com","threadId":"47651","inReplyTo":"robbat2-20180120T054223-685328376Z@orbis-terrarum.net","subject":"[PATCH] builtin/pull: respect verbosity settings in submodules","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-01-25T19:08:17Z","receivedAt":"2018-01-25T19:08:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"In a6d7eb2c7a (pull: optionally rebase submodules (remote submodule\nchanges only), 2017-06-23), we taught Git how to rebase submodules in\na pull. However we missed to pass on the verbosity settings.\n\nReported-by: Robin H. Johnson <robbat2@gentoo.org>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/pull.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 511dbbe0f6..1876271af9 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -574,6 +574,7 @@ static int rebase_submodules(void)\n \tcp.no_stdin = 1;\n \targv_array_pushl(&cp.args, \"submodule\", \"update\",\n \t\t\t\t   \"--recursive\", \"--rebase\", NULL);\n+\targv_push_verbosity(&cp.args);\n \n \treturn run_command(&cp);\n }\n@@ -586,6 +587,7 @@ static int update_submodules(void)\n \tcp.no_stdin = 1;\n \targv_array_pushl(&cp.args, \"submodule\", \"update\",\n \t\t\t\t   \"--recursive\", \"--checkout\", NULL);\n+\targv_push_verbosity(&cp.args);\n \n \treturn run_command(&cp);\n }\n-- \n2.16.0.rc1.238.g530d649a79-goog\n\n"},{"id":"337398","messageId":"xmqqk1w5agrt.fsf@gitster.mtv.corp.google.com","threadId":"47651","inReplyTo":"20180125190817.145041-1-sbeller@google.com","subject":"Re: [PATCH] builtin/pull: respect verbosity settings in submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-25T19:18:46Z","receivedAt":"2018-01-25T19:18:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> In a6d7eb2c7a (pull: optionally rebase submodules (remote submodule\n> changes only), 2017-06-23), we taught Git how to rebase submodules in\n> a pull. However we missed to pass on the verbosity settings.\n\nMakes sense.  Thanks.\n\n>\n> Reported-by: Robin H. Johnson <robbat2@gentoo.org>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>  builtin/pull.c | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/builtin/pull.c b/builtin/pull.c\n> index 511dbbe0f6..1876271af9 100644\n> --- a/builtin/pull.c\n> +++ b/builtin/pull.c\n> @@ -574,6 +574,7 @@ static int rebase_submodules(void)\n>  \tcp.no_stdin = 1;\n>  \targv_array_pushl(&cp.args, \"submodule\", \"update\",\n>  \t\t\t\t   \"--recursive\", \"--rebase\", NULL);\n> +\targv_push_verbosity(&cp.args);\n>  \n>  \treturn run_command(&cp);\n>  }\n> @@ -586,6 +587,7 @@ static int update_submodules(void)\n>  \tcp.no_stdin = 1;\n>  \targv_array_pushl(&cp.args, \"submodule\", \"update\",\n>  \t\t\t\t   \"--recursive\", \"--checkout\", NULL);\n> +\targv_push_verbosity(&cp.args);\n>  \n>  \treturn run_command(&cp);\n>  }\n"},{"id":"373572","messageId":"robbat2-20190410T062730-540884809Z@orbis-terrarum.net","threadId":"47651","inReplyTo":"robbat2-20180120T054223-685328376Z@orbis-terrarum.net","subject":"regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2019-04-10T06:41:05Z","receivedAt":"2019-04-10T06:41:14Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"A year ago, I raised <robbat2-20190410T062730-540884809Z@orbis-terrarum.net> as an issue,\nwhich lead to commit commit a56771a668dd4963675914bc5da0e1e015952dae.\n\nThe exact same workload somewhere between 2.18.0 and 2.19.0 has caused\nthe message to come back. I noticed it first in a 2.18.0->2.21.0\nupgrade, and did a partial bisect based on tags to trace it to 2.19.0.\n\n===\n$ git submodule foreach --quiet git pull origin master --quiet >/dev/null\nFrom git://anongit.gentoo.org/data/gentoo-news\n * branch            master     -> FETCH_HEAD\nFrom git://anongit.gentoo.org/data/glep\n * branch            master     -> FETCH_HEAD\n===\n\nI suspect it was a result of:\nea27893a65cc41cad2710466aa6a58866ff22f1e Merge branch 'pc/submodule-helper-foreach'\n\nBut I haven't done a full bisect to prove it yet.\n\nOn Sat, Jan 20, 2018 at 05:57:29AM +0000, Robin H. Johnson wrote:\n> Somewhere between 2.13.6 & 2.14.1 there's an output regression. I\n> haven't done a bisect to trace it down further yet.\n> \n> Specifically, --rebase --recurse-submodules=yes seems to cause --quiet\n> to not be effective anymore.\n> \n> Full commandline:\n> $ git pull --rebase --recurse-submodules --quiet\n> \n> In 2.13.6, there is no output, it's quiet as expect.\n> \n> In 2.14.1, you get:\n> HEAD is up to date.\n> Submodule path '_data/news': rebased into 'a50b763c338161b4621d23e9fa5cd6e11455d6ca'\n> HEAD is up to date.\n> Submodule path 'glep': rebased into 'e1f100ec3ba44ab1672d61cabf4690b355e46158'\n> \n> Steps to reproduction:\n> 1. git clone --recurse-submodules \\\n>  https://anongit.gentoo.org/git/sites/www.git\n> 2. cd www\n> 3. git submodule foreach --quiet git pull --quiet origin master\n> 4. git pull --rebase --recurse-submodules=yes --quiet\n> \n> Repeat step 4 for repeated bug output.\n> If you drop the --rebase, then you need to re-run step 3 first.\n> \n> -- \n> Robin Hugh Johnson\n> Gentoo Linux: Dev, Infra Lead, Foundation Treasurer\n> E-Mail   : robbat2@gentoo.org\n> GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\n> GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n\n\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Dev, Infra Lead, Foundation Treasurer\nE-Mail   : robbat2@gentoo.org\nGnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\nGnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n"},{"id":"373577","messageId":"20190410111834.GA25638@ash","threadId":"47651","inReplyTo":"robbat2-20190410T062730-540884809Z@orbis-terrarum.net","subject":"Re: regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-04-10T11:18:35Z","receivedAt":"2019-04-10T11:18:43Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Apr 10, 2019 at 06:41:05AM +0000, Robin H. Johnson wrote:\n> A year ago, I raised <robbat2-20190410T062730-540884809Z@orbis-terrarum.net> as an issue,\n> which lead to commit commit a56771a668dd4963675914bc5da0e1e015952dae.\n> \n> The exact same workload somewhere between 2.18.0 and 2.19.0 has caused\n> the message to come back. I noticed it first in a 2.18.0->2.21.0\n> upgrade, and did a partial bisect based on tags to trace it to 2.19.0.\n> \n> ===\n> $ git submodule foreach --quiet git pull origin master --quiet >/dev/null\n> From git://anongit.gentoo.org/data/gentoo-news\n>  * branch            master     -> FETCH_HEAD\n> From git://anongit.gentoo.org/data/glep\n>  * branch            master     -> FETCH_HEAD\n> ===\n\nIf you run this with GIT_TRACE=1, you can see that --quiet is passed\nto submodule--helper correctly.\n\ntrace: built-in: git submodule--helper foreach --quiet git pull --quiet origin master\n\nThe problem here is the option parser of this command would try to\nparse all options, so it considers both --quiet the same thing and are\nto tell \"submodule--foreach\" to be quiet, the second --quiet is not\npart of the \"git pull\" command anymore.\n\nSo the fix would be to pass \"--\" to stop option parsing.\nsubmodule--helper should not parse options it does not understand\nanyway. Something like this should work.\n\n-- 8< --\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6bcc4f1bd7..6394222628 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -571,7 +571,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \targc = parse_options(argc, argv, prefix, module_foreach_options,\n-\t\t\t     git_submodule_helper_usage, PARSE_OPT_KEEP_UNKNOWN);\n+\t\t\t     git_submodule_helper_usage, 0);\n \n \tif (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)\n \t\treturn 1;\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2c0fb6d723..a967b2890d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -346,7 +346,7 @@ cmd_foreach()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n #\n-- 8< --\n\nI'm a bit reluctant to follow up with a proper patch because I can't\ndigest the t5572-submodule-pull.sh tests. And we definitely need to\nadd a test case about --quiet to make sure it won't happen again.\n--\nDuy\n\n> \n> I suspect it was a result of:\n> ea27893a65cc41cad2710466aa6a58866ff22f1e Merge branch 'pc/submodule-helper-foreach'\n> \n> But I haven't done a full bisect to prove it yet.\n> \n> On Sat, Jan 20, 2018 at 05:57:29AM +0000, Robin H. Johnson wrote:\n> > Somewhere between 2.13.6 & 2.14.1 there's an output regression. I\n> > haven't done a bisect to trace it down further yet.\n> > \n> > Specifically, --rebase --recurse-submodules=yes seems to cause --quiet\n> > to not be effective anymore.\n> > \n> > Full commandline:\n> > $ git pull --rebase --recurse-submodules --quiet\n> > \n> > In 2.13.6, there is no output, it's quiet as expect.\n> > \n> > In 2.14.1, you get:\n> > HEAD is up to date.\n> > Submodule path '_data/news': rebased into 'a50b763c338161b4621d23e9fa5cd6e11455d6ca'\n> > HEAD is up to date.\n> > Submodule path 'glep': rebased into 'e1f100ec3ba44ab1672d61cabf4690b355e46158'\n> > \n> > Steps to reproduction:\n> > 1. git clone --recurse-submodules \\\n> >  https://anongit.gentoo.org/git/sites/www.git\n> > 2. cd www\n> > 3. git submodule foreach --quiet git pull --quiet origin master\n> > 4. git pull --rebase --recurse-submodules=yes --quiet\n> > \n> > Repeat step 4 for repeated bug output.\n> > If you drop the --rebase, then you need to re-run step 3 first.\n> > \n> > -- \n> > Robin Hugh Johnson\n> > Gentoo Linux: Dev, Infra Lead, Foundation Treasurer\n> > E-Mail   : robbat2@gentoo.org\n> > GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\n> > GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n> \n> \n> \n> -- \n> Robin Hugh Johnson\n> Gentoo Linux: Dev, Infra Lead, Foundation Treasurer\n> E-Mail   : robbat2@gentoo.org\n> GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\n> GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n\n\n"},{"id":"373712","messageId":"robbat2-20190412T063235-859985527Z@orbis-terrarum.net","threadId":"47651","inReplyTo":"20190410111834.GA25638@ash","subject":"Re: regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2019-04-12T07:08:55Z","receivedAt":"2019-04-12T07:09:02Z","isPatch":false,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"On Wed, Apr 10, 2019 at 06:18:35PM +0700, Duy Nguyen wrote:\n> ...\n\nThanks, I tested, and had good results in almost all of my tests.\n\nAlmost all: config setting of 'pull.rebase=preserve' \n===\n$ git submodule foreach --quiet git pull --quiet origin master >/dev/null\nSuccessfully rebased and updated detached HEAD.\nSuccessfully rebased and updated detached HEAD.\n$ git pull --rebase --recurse-submodules=yes --quiet >/dev/null\n$\n===\nLooking at git-rebase--preserve-merges.sh for this message, I think that\nshould be a separate patch to make it respect --quiet.\n\n> -- 8< --\n(snip patch, please add my DCO signed-off-by)\nTested-by: Robin H. Johnson <robbat2@gentoo.org>\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\n> -- 8< --\n> \n> I'm a bit reluctant to follow up with a proper patch because I can't\n> digest the t5572-submodule-pull.sh tests. And we definitely need to\n> add a test case about --quiet to make sure it won't happen again.\nFind testcase attached. Please submit in a series with your patch\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Dev, Infra Lead, Foundation Treasurer\nE-Mail   : robbat2@gentoo.org\nGnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\nGnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n\n\nFrom a57994f2d78134936521375ba9798a1b7418e230 Mon Sep 17 00:00:00 2001\nFrom: \"Robin H. Johnson\" <robbat2@gentoo.org>\nDate: Fri, 12 Apr 2019 00:00:07 -0700\nSubject: [PATCH] submodule foreach: test foreach option swallowing\n\nAdd a testcase for submodule foreach option parsing not knowing where to\nstop taking options, and accidently removing options intended for\nforeach target commands.\n\nCC: Duy Nguyen <pclouds@gmail.com>\nCC: Prathamesh Chavan <pc44800@gmail.com>\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\n---\n t/t7407-submodule-foreach.sh | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh\nindex 77729ac4aa..706ae762e0 100755\n--- a/t/t7407-submodule-foreach.sh\n+++ b/t/t7407-submodule-foreach.sh\n@@ -411,4 +411,14 @@ test_expect_success 'multi-argument command passed to foreach is not shell-evalu\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'option-like arguments passed to foreach commands are not lost' '\n+\t(\n+\t\tcd super &&\n+\t\tgit submodule foreach \"echo be --quiet\" > ../expected &&\n+\t\tgit submodule foreach echo be --quiet > ../actual\n+\t) &&\n+\tgrep -sq -e \"--quiet\" expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.21.0\n\n"},{"id":"373721","messageId":"CACsJy8DpFYiWJpRULKXEYFLnNU4Xnz5pNn1DHpb0bJnJrTwN3Q@mail.gmail.com","threadId":"47651","inReplyTo":"robbat2-20190412T063235-859985527Z@orbis-terrarum.net","subject":"Re: regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-04-12T09:25:34Z","receivedAt":"2019-04-12T09:26:03Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Apr 12, 2019 at 2:09 PM Robin H. Johnson <robbat2@gentoo.org> wrote:\n> > -- 8< --\n> (snip patch, please add my DCO signed-off-by)\n> Tested-by: Robin H. Johnson <robbat2@gentoo.org>\n> Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>\n> > -- 8< --\n> >\n> > I'm a bit reluctant to follow up with a proper patch because I can't\n> > digest the t5572-submodule-pull.sh tests. And we definitely need to\n> > add a test case about --quiet to make sure it won't happen again.\n> Find testcase attached. Please submit in a series with your patch\n\nClever. I was stuck thinking about actually pulling things. But yeah\n\"echo --quiet\" does the job just as well. Making patches (and maybe\ntrying to fix that pull --rebase --quiet thing as well)\n-- \nDuy\n"},{"id":"373733","messageId":"20190412100819.24863-1-pclouds@gmail.com","threadId":"47651","inReplyTo":"robbat2-20190410T062730-540884809Z@orbis-terrarum.net","subject":"[PATCH] submodule foreach: fix \"<command> --quiet\" not being respected","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2019-04-12T10:08:19Z","receivedAt":"2019-04-12T10:08:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Robin reported that\n\n    git submodule foreach --quiet git pull --quiet origin\n\nis not really quiet anymore [1]. \"git pull\" behaves as if --quiet is not\ngiven.\n\nThis happens because parseopt in submodule--helper will try to parse\nboth --quiet options as if they are foreach's options, not git-pull's.\nThe parsed options are removed from the command line. So when we do\npull later, we execute just this\n\n    git pull origin\n\nWhen calling submodule helper, adding \"--\" in front of \"git pull\" will\nstop parseopt for parsing options that do not really belong to\nsubmodule--helper foreach.\n\nPARSE_OPT_KEEP_UNKNOWN is removed as a safety measure. parseopt should\nnever see unknown options or something has gone wrong. There are also\na couple usage string update while I'm looking at them.\n\nWhile at it, I also add \"--\" to other subcommands that pass \"$@\" to\nsubmodule--helper. \"$@\" in these cases are paths and less likely to be\n--something-like-this. But the point still stands, git-submodule has\nparsed and classified what are options, what are paths. submodule--helper\nshould never consider paths passed by git-submodule to be options even\nif they look like one.\n\nThe test case is also contributed by Robin.\n\n[1] it should be quiet before fc1b9243cd (submodule: port submodule\n    subcommand 'foreach' from shell to C, 2018-05-10) because parseopt\n    can't accidentally eat options then.\n\nReported-by: Robin H. Johnson <robbat2@gentoo.org>\nTested-by: Robin H. Johnson <robbat2@gentoo.org>\nSigned-off-by: Robin H. Johnson <robbat2@gentoo.org>\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n I'm not trying to fix \"git pull --rebase --quiet\" (or \"git rebase\n --quiet\" in general) in the end, since that looks like a whole other\n can of worms.\n \n Not only git-rebase--preserve-merges.sh needs to respect --quiet (but\n which case? I don't have enough experience to say) but sequencer.c\n may need to be scanned too.\n\n builtin/submodule--helper.c  |  8 ++++----\n git-submodule.sh             | 11 ++++++-----\n t/t7407-submodule-foreach.sh | 10 ++++++++++\n 3 files changed, 20 insertions(+), 9 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 6bcc4f1bd7..59570b5e87 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -566,12 +566,12 @@ static int module_foreach(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] <command>\"),\n+\t\tN_(\"git submodule--helper foreach [--quiet] [--recursive] [--] <command>\"),\n \t\tNULL\n \t};\n \n \targc = parse_options(argc, argv, prefix, module_foreach_options,\n-\t\t\t     git_submodule_helper_usage, PARSE_OPT_KEEP_UNKNOWN);\n+\t\t\t     git_submodule_helper_usage, 0);\n \n \tif (module_list_compute(0, NULL, prefix, &pathspec, &list) < 0)\n \t\treturn 1;\n@@ -709,7 +709,7 @@ static int module_init(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper init [<path>]\"),\n+\t\tN_(\"git submodule--helper init [<options>] [<path>]\"),\n \t\tNULL\n \t};\n \n@@ -2096,7 +2096,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n \t};\n \n \tconst char *const git_submodule_helper_usage[] = {\n-\t\tN_(\"git submodule--helper embed-git-dir [<path>...]\"),\n+\t\tN_(\"git submodule--helper asorb-git-dirs [<options>] [<path>...]\"),\n \t\tNULL\n \t};\n \ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 2c0fb6d723..d33f5d8bb4 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -346,7 +346,7 @@ cmd_foreach()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper foreach ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n #\n@@ -377,7 +377,7 @@ cmd_init()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet}  \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper init ${GIT_QUIET:+--quiet} -- \"$@\"\n }\n \n #\n@@ -413,7 +413,7 @@ cmd_deinit()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${prefix:+--prefix \"$prefix\"} ${force:+--force} ${deinit_all:+--all} \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} submodule--helper deinit ${GIT_QUIET:+--quiet} ${prefix:+--prefix \"$prefix\"} ${force:+--force} ${deinit_all:+--all} -- \"$@\"\n }\n \n is_tip_reachable () (\n@@ -542,6 +542,7 @@ cmd_update()\n \t\t${depth:+--depth \"$depth\"} \\\n \t\t$recommend_shallow \\\n \t\t$jobs \\\n+\t\t-- \\\n \t\t\"$@\" || echo \"#unmatched\" $?\n \t} | {\n \terr=\n@@ -934,7 +935,7 @@ cmd_status()\n \t\tshift\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper status ${GIT_QUIET:+--quiet} ${cached:+--cached} ${recursive:+--recursive} -- \"$@\"\n }\n #\n # Sync remote urls for submodules\n@@ -967,7 +968,7 @@ cmd_sync()\n \t\tesac\n \tdone\n \n-\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} \"$@\"\n+\tgit ${wt_prefix:+-C \"$wt_prefix\"} ${prefix:+--super-prefix \"$prefix\"} submodule--helper sync ${GIT_QUIET:+--quiet} ${recursive:+--recursive} -- \"$@\"\n }\n \n cmd_absorbgitdirs()\ndiff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh\nindex 77729ac4aa..706ae762e0 100755\n--- a/t/t7407-submodule-foreach.sh\n+++ b/t/t7407-submodule-foreach.sh\n@@ -411,4 +411,14 @@ test_expect_success 'multi-argument command passed to foreach is not shell-evalu\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'option-like arguments passed to foreach commands are not lost' '\n+\t(\n+\t\tcd super &&\n+\t\tgit submodule foreach \"echo be --quiet\" > ../expected &&\n+\t\tgit submodule foreach echo be --quiet > ../actual\n+\t) &&\n+\tgrep -sq -e \"--quiet\" expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.21.0.682.g30d2204636\n\n"},{"id":"373752","messageId":"robbat2-20190412T172121-535310801Z@orbis-terrarum.net","threadId":"47651","inReplyTo":"20190412100819.24863-1-pclouds@gmail.com","subject":"Re: [PATCH] submodule foreach: fix \"<command> --quiet\" not being respected","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2019-04-12T17:22:15Z","receivedAt":"2019-04-12T17:22:22Z","isPatch":true,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"On Fri, Apr 12, 2019 at 05:08:19PM +0700, Nguyễn Thái Ngọc Duy wrote:\n> @@ -2096,7 +2096,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n>  \t};\n>  \n>  \tconst char *const git_submodule_helper_usage[] = {\n> -\t\tN_(\"git submodule--helper embed-git-dir [<path>...]\"),\n> +\t\tN_(\"git submodule--helper asorb-git-dirs [<options>] [<path>...]\"),\nNit typo here: s/asorb/absorb/\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Dev, Infra Lead, Foundation Treasurer\nE-Mail   : robbat2@gentoo.org\nGnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\nGnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136\n"},{"id":"373840","messageId":"xmqqtvf0ug7c.fsf@gitster-ct.c.googlers.com","threadId":"47651","inReplyTo":"robbat2-20190412T172121-535310801Z@orbis-terrarum.net","subject":"Re: [PATCH] submodule foreach: fix \"<command> --quiet\" not being respected","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-04-15T02:59:03Z","receivedAt":"2019-04-15T02:59:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Robin H. Johnson\" <robbat2@gentoo.org> writes:\n\n> On Fri, Apr 12, 2019 at 05:08:19PM +0700, Nguyễn Thái Ngọc Duy wrote:\n>> @@ -2096,7 +2096,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)\n>>  \t};\n>>  \n>>  \tconst char *const git_submodule_helper_usage[] = {\n>> -\t\tN_(\"git submodule--helper embed-git-dir [<path>...]\"),\n>> +\t\tN_(\"git submodule--helper asorb-git-dirs [<options>] [<path>...]\"),\n> Nit typo here: s/asorb/absorb/\n\nWill locally tweak while queueing.  Thanks, both.\n"},{"id":"373878","messageId":"nycvar.QRO.7.76.6.1904151635320.12614@tvgsbejvaqbjf.bet","threadId":"47651","inReplyTo":"robbat2-20190412T063235-859985527Z@orbis-terrarum.net","subject":"Re: regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-04-15T14:40:30Z","receivedAt":"2019-04-15T14:40:50Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Robin,\n\nOn Fri, 12 Apr 2019, Robin H. Johnson wrote:\n\n> Looking at git-rebase--preserve-merges.sh for this message, I think that\n> should be a separate patch to make it respect --quiet.\n\nPlease note that `git rebase --preserve-merges` will be deprecated as of\nthe next Git version (see https://github.com/gitgitgadget/git/pull/158 for\ndetails).\n\nSo I don't think it is worth the bother to fix that mode with respect to\n--quiet.\n\nCiao,\nJohannes\n"},{"id":"373930","messageId":"CACsJy8AasZkzkR4apr1cywi1wpP92FOjAN2Oc7GYDYv4NPnXdQ@mail.gmail.com","threadId":"47651","inReplyTo":"CAODn77oL6sj5zvxgPGw=4TNqmnSeBq4=j2r2nx_51YHooECo7w@mail.gmail.com","subject":"Re: regression AGAIN in output of git-pull --rebase --recurse-submodules=yes --quiet","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-04-16T07:48:30Z","receivedAt":"2019-04-16T07:48:59Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Apr 16, 2019 at 1:31 PM Paul Morelle <paul.morelle@gmail.com> wrote:\n>> The problem here is the option parser of this command would try to\n>> parse all options, so it considers both --quiet the same thing and are\n>> to tell \"submodule--foreach\" to be quiet, the second --quiet is not\n>> part of the \"git pull\" command anymore.\n>>\n>> So the fix would be to pass \"--\" to stop option parsing.\n>> submodule--helper should not parse options it does not understand\n>> anyway. Something like this should work.\n>\n>\n> My expectation as a user (and probably Robin's too) would be that `git submodule foreach` stops parsing arguments at `--` or at the first not-recognized argument, whichever is encountered first. The rest of the arguments would then be considered as the command.\n\nI don't think I change any visible behavior though (or at least trying\nnot to). There are two command line parsers, the \"front\" one is in\ngit-submodule.sh and should do what you describe (or whatever the\ncurrent behavior is) and there's an internal one for \"git\nsubmodule--helper\" which is more like internal API than anything.\n\nThe change here is to stop the internal parser from accidentally\ninterpret options that belong to the foreach's command. The \"--\" and\nfirst non-recognized argument should be handled correctly by the front\nparser.\n\nThe exact behavior of this front parser, I can't tell (I'm nowhere\nnear expert level of submodules) but yeah it should stop at either\n`--` or the first non-option argument (e.g. something that does not\nstart with '-'). An argument that looks like an option (i.e. starts\nwith '-') but not recognized should result in an error. This is pretty\nmuch standard behavior for all other commands, but I have not tested\nthis with git-submodule.sh.\n\n> This would slightly break the retrocompatibility, but would also avoid similar bugs in the future.\n-- \nDuy\n"}]}