push: --dry-run updates submodules when --recurse-submodules=on-demand

This patch adds a test to illustrate how push run with --dry-run doesn't actually perform a dry-run when push is configured to push submodules on-demand. Instead all submodules which need to be pushed are actually pushed to their remotes while any updates for the superproject are performed as a dry-run. This is a bug and not the intended behaviour of a dry-run. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed Nov 17, 2016 at 10:46 UTC 1aa73658405ad423127b3c14ac13e46f9ad0163a
1 file changed +24
t/t5531-deep-submodule-push.sh
+24
@@ -427,7 +427,31 @@ test_expect_success 'push unpushable submodule recursively fails' '
427 cd submodule.git &&
428 git rev-parse master >../actual
429 ) &&
430 + test_when_finished git -C work reset --hard master^ &&
431 test_cmp expected actual
432 '
433
434 +test_expect_failure 'push --dry-run does not recursively update submodules' '
435 + (
436 + cd work/gar/bage &&
437 + git checkout master &&
438 + git rev-parse master >../../../expected_submodule &&
439 + > junk9 &&
440 + git add junk9 &&
441 + git commit -m "Ninth junk" &&
442 +
443 + # Go up to 'work' directory
444 + cd ../.. &&
445 + git checkout master &&
446 + git rev-parse master >../expected_pub &&
447 + git add gar/bage &&
448 + git commit -m "Ninth commit for gar/bage" &&
449 + git push --dry-run --recurse-submodules=on-demand ../pub.git master
450 + ) &&
451 + git -C submodule.git rev-parse master >actual_submodule &&
452 + git -C pub.git rev-parse master >actual_pub &&
453 + test_cmp expected_pub actual_pub &&
454 + test_cmp expected_submodule actual_submodule
455 +'
456 +
457 test_done