3 # Copyright (c) 2008 David Aguilar
6 test_description
='git submodule sync
8 These tests exercise the "git submodule sync" subcommand.
13 test_expect_success setup
'
17 git commit -m upstream &&
19 git clone super submodule &&
21 git submodule add ../submodule submodule &&
23 git commit -m "submodule"
25 git clone super super-clone &&
26 (cd super-clone && git submodule update --init) &&
27 git clone super empty-clone &&
28 (cd empty-clone && git submodule init) &&
29 git clone super top-only-clone &&
30 git clone super relative-clone &&
31 (cd relative-clone && git submodule update --init)
34 test_expect_success
'change submodule' '
36 echo second line >> file &&
38 git commit -a -m "change submodule"
42 test_expect_success
'change submodule url' '
45 git checkout master &&
48 mv submodule moved-submodule &&
50 git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
52 git commit -a -m moved-submodule
56 test_expect_success
'"git submodule sync" should update submodule URLs' '
58 git pull --no-recurse-submodules &&
61 test -d "$(cd super-clone/submodule &&
62 git config remote.origin.url
64 (cd super-clone/submodule &&
65 git checkout master &&
69 test -d "$(git config submodule.submodule.url)"
73 test_expect_success
'"git submodule sync" should update known submodule URLs' '
77 test -d "$(git config submodule.submodule.url)"
81 test_expect_success
'"git submodule sync" should not vivify uninteresting submodule' '
85 test -z "$(git config submodule.submodule.url)" &&
86 git submodule sync submodule &&
87 test -z "$(git config submodule.submodule.url)"
91 test_expect_success
'"git submodule sync" handles origin URL of the form foo' '
93 git remote set-url origin foo &&
96 #actual fails with: "cannot strip off url foo
97 test "$(git config remote.origin.url)" = "../submodule"
102 test_expect_success
'"git submodule sync" handles origin URL of the form foo/bar' '
103 (cd relative-clone &&
104 git remote set-url origin foo/bar &&
105 git submodule sync &&
107 #actual foo/submodule
108 test "$(git config remote.origin.url)" = "../foo/submodule"
113 test_expect_success
'"git submodule sync" handles origin URL of the form ./foo' '
114 (cd relative-clone &&
115 git remote set-url origin ./foo &&
116 git submodule sync &&
119 test "$(git config remote.origin.url)" = "../submodule"
124 test_expect_success
'"git submodule sync" handles origin URL of the form ./foo/bar' '
125 (cd relative-clone &&
126 git remote set-url origin ./foo/bar &&
127 git submodule sync &&
129 #actual ./foo/submodule
130 test "$(git config remote.origin.url)" = "../foo/submodule"
135 test_expect_success
'"git submodule sync" handles origin URL of the form ../foo' '
136 (cd relative-clone &&
137 git remote set-url origin ../foo &&
138 git submodule sync &&
141 test "$(git config remote.origin.url)" = "../../submodule"
146 test_expect_success
'"git submodule sync" handles origin URL of the form ../foo/bar' '
147 (cd relative-clone &&
148 git remote set-url origin ../foo/bar &&
149 git submodule sync &&
151 #actual ../foo/submodule
152 test "$(git config remote.origin.url)" = "../../foo/submodule"
157 test_expect_success
'"git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' '
158 (cd relative-clone &&
159 git remote set-url origin ../foo/bar &&
164 git add .gitignore &&
166 git commit -m "initial commit" ) &&
167 git submodule add ../bar/a/b/c ./a/b/c &&
168 git submodule sync &&
170 #actual ../foo/bar/a/b/c
171 test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"