summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-04-05 17:47:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-11 07:45:26 (GMT)
commit06bf4ad1db92c32af38e16d9b7f928edbd647780 (patch)
tree2633f6ac10cfc7ceaa58972990b7d3a82afa5d0d /t
parent93481a6b89be41086997ecaf9454f0c0bf6a961e (diff)
downloadgit-06bf4ad1db92c32af38e16d9b7f928edbd647780.zip
git-06bf4ad1db92c32af38e16d9b7f928edbd647780.tar.gz
git-06bf4ad1db92c32af38e16d9b7f928edbd647780.tar.bz2
push: propagate remote and refspec with --recurse-submodules
Teach "push --recurse-submodules" to propagate, if given a name as remote, the provided remote and refspec recursively to the pushes performed in the submodules. The push will therefore only succeed if all submodules have a remote with such a name configured. Note that "push --recurse-submodules" with a path or URL as remote will not propagate the remote or refspec and instead use the default remote and refspec configured in the submodule, preserving the current behavior. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t5531-deep-submodule-push.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index f55137f..57ba322 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -475,4 +475,56 @@ test_expect_success 'push only unpushed submodules recursively' '
test_cmp expected_pub actual_pub
'
+test_expect_success 'push propagating the remotes name to a submodule' '
+ git -C work remote add origin ../pub.git &&
+ git -C work remote add pub ../pub.git &&
+
+ > work/gar/bage/junk10 &&
+ git -C work/gar/bage add junk10 &&
+ git -C work/gar/bage commit -m "Tenth junk" &&
+ git -C work add gar/bage &&
+ git -C work commit -m "Tenth junk added to gar/bage" &&
+
+ # Fails when submodule does not have a matching remote
+ test_must_fail git -C work push --recurse-submodules=on-demand pub master &&
+ # Succeeds when submodules has matching remote and refspec
+ git -C work push --recurse-submodules=on-demand origin master &&
+
+ git -C submodule.git rev-parse master >actual_submodule &&
+ git -C pub.git rev-parse master >actual_pub &&
+ git -C work/gar/bage rev-parse master >expected_submodule &&
+ git -C work rev-parse master >expected_pub &&
+ test_cmp expected_submodule actual_submodule &&
+ test_cmp expected_pub actual_pub
+'
+
+test_expect_success 'push propagating refspec to a submodule' '
+ > work/gar/bage/junk11 &&
+ git -C work/gar/bage add junk11 &&
+ git -C work/gar/bage commit -m "Eleventh junk" &&
+
+ git -C work checkout branch2 &&
+ git -C work add gar/bage &&
+ git -C work commit -m "updating gar/bage in branch2" &&
+
+ # Fails when submodule does not have a matching branch
+ test_must_fail git -C work push --recurse-submodules=on-demand origin branch2 &&
+ # Fails when refspec includes an object id
+ test_must_fail git -C work push --recurse-submodules=on-demand origin \
+ "$(git -C work rev-parse branch2):refs/heads/branch2" &&
+ # Fails when refspec includes 'HEAD' as it is unsupported at this time
+ test_must_fail git -C work push --recurse-submodules=on-demand origin \
+ HEAD:refs/heads/branch2 &&
+
+ git -C work/gar/bage branch branch2 master &&
+ git -C work push --recurse-submodules=on-demand origin branch2 &&
+
+ git -C submodule.git rev-parse branch2 >actual_submodule &&
+ git -C pub.git rev-parse branch2 >actual_pub &&
+ git -C work/gar/bage rev-parse branch2 >expected_submodule &&
+ git -C work rev-parse branch2 >expected_pub &&
+ test_cmp expected_submodule actual_submodule &&
+ test_cmp expected_pub actual_pub
+'
+
test_done