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 &&
32 git submodule add ../submodule submodule &&
34 git commit -m "submodule" &&
35 git submodule init submodule
38 echo "line2" > file &&
40 git commit -m "Commit 2"
44 git pull --rebase origin
47 git commit -m "submodule update"
51 test_expect_success
'submodule update detaching the HEAD ' '
52 (cd super/submodule &&
53 git reset --hard HEAD~1
59 git submodule update submodule &&
65 test_expect_success
'submodule update --rebase staying on master' '
66 (cd super/submodule &&
73 git submodule update --rebase submodule &&
79 test_expect_success
'submodule update --merge staying on master' '
80 (cd super/submodule &&
81 git reset --hard HEAD~1
87 git submodule update --merge submodule &&
93 test_expect_success
'submodule update - rebase in .git/config' '
95 git config submodule.submodule.update rebase
97 (cd super/submodule &&
98 git reset --hard HEAD~1
104 git submodule update submodule &&
110 test_expect_success
'submodule update - checkout in .git/config but --rebase given' '
112 git config submodule.submodule.update checkout
114 (cd super/submodule &&
115 git reset --hard HEAD~1
121 git submodule update --rebase submodule &&
127 test_expect_success
'submodule update - merge in .git/config' '
129 git config submodule.submodule.update merge
131 (cd super/submodule &&
132 git reset --hard HEAD~1
138 git submodule update submodule &&
144 test_expect_success
'submodule update - checkout in .git/config but --merge given' '
146 git config submodule.submodule.update checkout
148 (cd super/submodule &&
149 git reset --hard HEAD~1
155 git submodule update --merge submodule &&
161 test_expect_success
'submodule update - checkout in .git/config' '
163 git config submodule.submodule.update checkout
165 (cd super/submodule &&
166 git reset --hard HEAD^
172 git submodule update submodule &&
178 test_expect_success
'submodule init picks up rebase' '
180 git config submodule.rebasing.url git://non-existing/git &&
181 git config submodule.rebasing.path does-not-matter &&
182 git config submodule.rebasing.update rebase &&
183 git submodule init rebasing &&
184 test "rebase" = $(git config submodule.rebasing.update)
188 test_expect_success
'submodule init picks up merge' '
190 git config submodule.merging.url git://non-existing/git &&
191 git config submodule.merging.path does-not-matter &&
192 git config submodule.merging.update merge &&
193 git submodule init merging &&
194 test "merge" = $(git config submodule.merging.update)