summaryrefslogtreecommitdiff
path: root/t/t5531-deep-submodule-push.sh
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-07-20 17:40:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-20 21:58:26 (GMT)
commitc7be7201a7b71f590325f0d858f909a4c0b443f6 (patch)
tree1880ae1f4b6a9811f249c43f62e1c62167f613ae /t/t5531-deep-submodule-push.sh
parent06bf4ad1db92c32af38e16d9b7f928edbd647780 (diff)
downloadgit-c7be7201a7b71f590325f0d858f909a4c0b443f6.zip
git-c7be7201a7b71f590325f0d858f909a4c0b443f6.tar.gz
git-c7be7201a7b71f590325f0d858f909a4c0b443f6.tar.bz2
submodule--helper: teach push-check to handle HEAD
In 06bf4ad1d (push: propagate remote and refspec with --recurse-submodules) push was taught how to propagate a refspec down to submodules when the '--recurse-submodules' flag is given. The only refspecs that are allowed to be propagated are ones which name a ref which exists in both the superproject and the submodule, with the caveat that 'HEAD' was disallowed. This patch teaches push-check (the submodule helper which determines if a refspec can be propagated to a submodule) to permit propagating 'HEAD' if and only if the superproject and the submodule both have the same named branch checked out and the submodule is not in a detached head state. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5531-deep-submodule-push.sh')
-rwxr-xr-xt/t5531-deep-submodule-push.sh25
1 files changed, 24 insertions, 1 deletions
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh
index 57ba322..9e4410b 100755
--- a/t/t5531-deep-submodule-push.sh
+++ b/t/t5531-deep-submodule-push.sh
@@ -512,7 +512,8 @@ test_expect_success 'push propagating refspec to a submodule' '
# 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
+ # Fails when refspec includes HEAD and parent and submodule do not
+ # have the same named branch checked out
test_must_fail git -C work push --recurse-submodules=on-demand origin \
HEAD:refs/heads/branch2 &&
@@ -527,4 +528,26 @@ test_expect_success 'push propagating refspec to a submodule' '
test_cmp expected_pub actual_pub
'
+test_expect_success 'push propagating HEAD refspec to a submodule' '
+ git -C work/gar/bage checkout branch2 &&
+ > work/gar/bage/junk12 &&
+ git -C work/gar/bage add junk12 &&
+ git -C work/gar/bage commit -m "Twelfth junk" &&
+
+ git -C work checkout branch2 &&
+ git -C work add gar/bage &&
+ git -C work commit -m "updating gar/bage in branch2" &&
+
+ # Passes since the superproject and submodules HEAD are both on branch2
+ git -C work push --recurse-submodules=on-demand origin \
+ HEAD:refs/heads/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