submodule: document failure to handle relative superproject origin URLs
This test case documents several cases where handling of relative superproject origin URLs doesn't produce an expected result. submodule.{sub}.url in the superproject is incorrect in these cases: foo ./foo ./foo/bar The remote.origin.url of the submodule is incorrect in the above cases and also when the superproject origin URL is like: foo/bar ../foo ../foo/bar Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jon Seymour committed
Jun 3, 2012 at 19:46 UTC
49301c64f3612d68058efb428a74133ac6e4a071
2 files changed
+123
-1
t/t7400-submodule-basic.sh
+34
@@ -564,6 +564,18 @@ test_expect_success '../subrepo works with scp-style URL - user@host:path/to/rep
564
)
565
'
566
567
+test_expect_failure '../subrepo works with relative local path - foo' '
568
+ (
569
+ cd reltest &&
570
+ cp pristine-.git-config .git/config &&
571
+ cp pristine-.gitmodules .gitmodules &&
572
+ git config remote.origin.url foo &&
573
+ # actual: fails with an error
574
+ git submodule init &&
575
+ test "$(git config submodule.sub.url)" = subrepo
576
+ )
577
+'
578
+
579
test_expect_success '../subrepo works with relative local path - foo/bar' '
580
(
581
cd reltest &&
@@ -575,6 +587,28 @@ test_expect_success '../subrepo works with relative local path - foo/bar' '
587
)
588
'
589
590
+test_expect_failure '../subrepo works with relative local path - ./foo' '
591
+ (
592
+ cd reltest &&
593
+ cp pristine-.git-config .git/config &&
594
+ cp pristine-.gitmodules .gitmodules &&
595
+ git config remote.origin.url ./foo &&
596
+ git submodule init &&
597
+ test "$(git config submodule.sub.url)" = subrepo
598
+ )
599
+'
600
+
601
+test_expect_failure '../subrepo works with relative local path - ./foo/bar' '
602
+ (
603
+ cd reltest &&
604
+ cp pristine-.git-config .git/config &&
605
+ cp pristine-.gitmodules .gitmodules &&
606
+ git config remote.origin.url ./foo/bar &&
607
+ git submodule init &&
608
+ test "$(git config submodule.sub.url)" = foo/subrepo
609
+ )
610
+'
611
+
612
test_expect_success '../subrepo works with relative local path - ../foo' '
613
(
614
cd reltest &&
t/t7403-submodule-sync.sh
+89
-1
@@ -26,7 +26,9 @@ test_expect_success setup '
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
29
+ git clone super top-only-clone &&
30
+ git clone super relative-clone &&
31
+ (cd relative-clone && git submodule update --init)
32
'
33
34
test_expect_success 'change submodule' '
@@ -86,4 +88,90 @@ test_expect_success '"git submodule sync" should not vivify uninteresting submod
88
)
89
'
90
91
+test_expect_failure '"git submodule sync" handles origin URL of the form foo' '
92
+ (cd relative-clone &&
93
+ git remote set-url origin foo &&
94
+ git submodule sync &&
95
+ (cd submodule &&
96
+ #actual fails with: "cannot strip off url foo
97
+ test "$(git config remote.origin.url)" = "../submodule"
98
+ )
99
+ )
100
+'
101
+
102
+test_expect_failure '"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 &&
106
+ (cd submodule &&
107
+ #actual foo/submodule
108
+ test "$(git config remote.origin.url)" = "../foo/submodule"
109
+ )
110
+ )
111
+'
112
+
113
+test_expect_failure '"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 &&
117
+ (cd submodule &&
118
+ #actual ./submodule
119
+ test "$(git config remote.origin.url)" = "../submodule"
120
+ )
121
+ )
122
+'
123
+
124
+test_expect_failure '"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 &&
128
+ (cd submodule &&
129
+ #actual ./foo/submodule
130
+ test "$(git config remote.origin.url)" = "../foo/submodule"
131
+ )
132
+ )
133
+'
134
+
135
+test_expect_failure '"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 &&
139
+ (cd submodule &&
140
+ #actual ../submodule
141
+ test "$(git config remote.origin.url)" = "../../submodule"
142
+ )
143
+ )
144
+'
145
+
146
+test_expect_failure '"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 &&
150
+ (cd submodule &&
151
+ #actual ../foo/submodule
152
+ test "$(git config remote.origin.url)" = "../../foo/submodule"
153
+ )
154
+ )
155
+'
156
+
157
+test_expect_failure '"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 &&
160
+ mkdir -p a/b/c &&
161
+ ( cd a/b/c &&
162
+ git init &&
163
+ :> .gitignore &&
164
+ git add .gitignore &&
165
+ test_tick &&
166
+ git commit -m "initial commit" ) &&
167
+ git submodule add ../bar/a/b/c ./a/b/c &&
168
+ git submodule sync &&
169
+ (cd a/b/c &&
170
+ #actual ../foo/bar/a/b/c
171
+ test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
172
+ )
173
+ )
174
+'
175
+
176
+
177
test_done