Skip to content

Commit 968eecb

Browse files
committed
Merge branch 'ms/submodule-foreach-fix'
"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
2 parents 88b1075 + 30db18b commit 968eecb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
540540
if (info->quiet)
541541
argv_array_push(&cpr.args, "--quiet");
542542

543+
argv_array_push(&cpr.args, "--");
543544
argv_array_pushv(&cpr.args, info->argv);
544545

545546
if (run_command(&cpr))

t/t7407-submodule-foreach.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,11 @@ test_expect_success 'option-like arguments passed to foreach commands are not lo
421421
test_cmp expected actual
422422
'
423423

424+
test_expect_success 'option-like arguments passed to foreach recurse correctly' '
425+
git -C clone2 submodule foreach --recursive "echo be --an-option" >expect &&
426+
git -C clone2 submodule foreach --recursive echo be --an-option >actual &&
427+
grep -e "--an-option" expect &&
428+
test_cmp expect actual
429+
'
430+
424431
test_done

0 commit comments

Comments
 (0)