diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index d38113a31aeb38..61a5bfb1f2be0e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -539,6 +539,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 77729ac4aa1873..57e4b7f990d60c 100755 --- a/t/t7407-submodule-foreach.sh +++ b/t/t7407-submodule-foreach.sh @@ -411,4 +411,11 @@ test_expect_success 'multi-argument command passed to foreach is not shell-evalu 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