aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-07-29 12:38:18 -0700
committerJunio C Hamano <gitster@pobox.com>2019-07-29 12:38:18 -0700
commit292a0de9982aff5e4f952214c1b9f762d8a1585a (patch)
tree6948ec1ee4bee6865b761aa200c8f4b7e9c9bdb7
parentMerge branch 'js/rebase-reschedule-applies-only-to-interactive' into maint (diff)
parentsubmodule foreach: fix recursion of options (diff)
downloadgit-292a0de9982aff5e4f952214c1b9f762d8a1585a.tar.gz
git-292a0de9982aff5e4f952214c1b9f762d8a1585a.zip
Merge branch 'ms/submodule-foreach-fix' into maint
"git submodule foreach" did not protect command line options passed to the command to be run in each submodule correctly, when the "--recursive" option was in use. * ms/submodule-foreach-fix: submodule foreach: fix recursion of options
-rw-r--r--builtin/submodule--helper.c1
-rwxr-xr-xt/t7407-submodule-foreach.sh7
2 files changed, 8 insertions, 0 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 0bf4aa088e..afaf0819c9 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -540,6 +540,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
if (info->quiet)
argv_array_push(&cpr.args, "--quiet");
+ argv_array_push(&cpr.args, "--");
argv_array_pushv(&cpr.args, info->argv);
if (run_command(&cpr))
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index 706ae762e0..6b2aa917e1 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -421,4 +421,11 @@ test_expect_success 'option-like arguments passed to foreach commands are not lo
test_cmp expected actual
'
+test_expect_success 'option-like arguments passed to foreach recurse correctly' '
+ git -C clone2 submodule foreach --recursive "echo be --an-option" >expect &&
+ git -C clone2 submodule foreach --recursive echo be --an-option >actual &&
+ grep -e "--an-option" expect &&
+ test_cmp expect actual
+'
+
test_done