3 # Copyright (c) 2009 Red Hat, Inc.
6 test_description='Test updating submodules
8 This test verifies that "git submodule update" detaches the HEAD of the
9 submodule and "git submodule update --rebase/--merge" does not detach the HEAD.
17 sha_master=`git rev-list --max-count=1 master`
18 sha_head=`git rev-list --max-count=1 HEAD`
20 test "$sha_master" = "$sha_head"
24 test_expect_success 'setup a submodule tree' '
28 git commit -m upstream &&
30 git clone super submodule &&
31 git clone super rebasing &&
32 git clone super merging &&
34 git submodule add ../submodule submodule &&
36 git commit -m "submodule" &&
37 git submodule init submodule
40 echo "line2" > file &&
42 git commit -m "Commit 2"
46 git pull --rebase origin
49 git commit -m "submodule update"
52 git submodule add ../rebasing rebasing &&
54 git commit -m "rebasing"
57 git submodule add ../merging merging &&
59 git commit -m "rebasing"
63 test_expect_success 'submodule update detaching the HEAD ' '
64 (cd super/submodule &&
65 git reset --hard HEAD~1
71 git submodule update submodule &&
77 test_expect_success 'submodule update --rebase staying on master' '
78 (cd super/submodule &&
85 git submodule update --rebase submodule &&
91 test_expect_success 'submodule update --merge staying on master' '
92 (cd super/submodule &&
93 git reset --hard HEAD~1
99 git submodule update --merge submodule &&
105 test_expect_success 'submodule update - rebase in .git/config' '
107 git config submodule.submodule.update rebase
109 (cd super/submodule &&
110 git reset --hard HEAD~1
116 git submodule update submodule &&
122 test_expect_success 'submodule update - checkout in .git/config but --rebase given' '
124 git config submodule.submodule.update checkout
126 (cd super/submodule &&
127 git reset --hard HEAD~1
133 git submodule update --rebase submodule &&
139 test_expect_success 'submodule update - merge in .git/config' '
141 git config submodule.submodule.update merge
143 (cd super/submodule &&
144 git reset --hard HEAD~1
150 git submodule update submodule &&
156 test_expect_success 'submodule update - checkout in .git/config but --merge given' '
158 git config submodule.submodule.update checkout
160 (cd super/submodule &&
161 git reset --hard HEAD~1
167 git submodule update --merge submodule &&
173 test_expect_success 'submodule update - checkout in .git/config' '
175 git config submodule.submodule.update checkout
177 (cd super/submodule &&
178 git reset --hard HEAD^
184 git submodule update submodule &&
190 test_expect_success 'submodule init picks up rebase' '
192 git config -f .gitmodules submodule.rebasing.update rebase &&
193 git submodule init rebasing &&
194 test "rebase" = "$(git config submodule.rebasing.update)"
198 test_expect_success 'submodule init picks up merge' '
200 git config -f .gitmodules submodule.merging.update merge &&
201 git submodule init merging &&
202 test "merge" = "$(git config submodule.merging.update)"