]> git.proxmox.com Git - libgit2.git/blame - tests/libgit2/submodule/lookup.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / submodule / lookup.c
CommitLineData
aa13bf05
RB
1#include "clar_libgit2.h"
2#include "submodule_helpers.h"
1e9dd60f 3#include "git2/sys/repository.h"
a34c4f8d 4#include "repository.h"
22a2d3d5 5#include "futils.h"
aa13bf05
RB
6
7static git_repository *g_repo = NULL;
8
9void test_submodule_lookup__initialize(void)
10{
14997dc5 11 g_repo = setup_fixture_submod2();
aa13bf05
RB
12}
13
eae0bfdc
PP
14void test_submodule_lookup__cleanup(void)
15{
16 cl_git_sandbox_cleanup();
17}
18
aa13bf05
RB
19void test_submodule_lookup__simple_lookup(void)
20{
a15c7802 21 assert_submodule_exists(g_repo, "sm_unchanged");
aa13bf05
RB
22
23 /* lookup pending change in .gitmodules that is not in HEAD */
a15c7802 24 assert_submodule_exists(g_repo, "sm_added_and_uncommited");
aa13bf05 25
a15c7802
RB
26 /* lookup pending change in .gitmodules that is not in HEAD nor index */
27 assert_submodule_exists(g_repo, "sm_gitmodules_only");
fed886d9 28
aa13bf05 29 /* lookup git repo subdir that is not added as submodule */
a15c7802 30 refute_submodule_exists(g_repo, "not-submodule", GIT_EEXISTS);
aa13bf05
RB
31
32 /* lookup existing directory that is not a submodule */
a15c7802 33 refute_submodule_exists(g_repo, "just_a_dir", GIT_ENOTFOUND);
aa13bf05
RB
34
35 /* lookup existing file that is not a submodule */
a15c7802 36 refute_submodule_exists(g_repo, "just_a_file", GIT_ENOTFOUND);
aa13bf05
RB
37
38 /* lookup non-existent item */
a15c7802 39 refute_submodule_exists(g_repo, "no_such_file", GIT_ENOTFOUND);
c28a5c97
CMN
40
41 /* lookup a submodule by path with a trailing slash */
42 assert_submodule_exists(g_repo, "sm_added_and_uncommited/");
aa13bf05
RB
43}
44
c25aa7cd
PP
45void test_submodule_lookup__can_be_dupped(void)
46{
47 git_submodule *sm;
48 git_submodule *sm_duplicate;
49 const char *oid = "480095882d281ed676fe5b863569520e54a7d5c0";
50
51 /* Check original */
52 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
53 cl_assert(git_submodule_owner(sm) == g_repo);
54 cl_assert_equal_s("sm_unchanged", git_submodule_name(sm));
55 cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
56 cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
57
58 cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
59 cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
60 cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
61
62 cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
63 cl_assert(git_submodule_update_strategy(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
64
65 /* Duplicate and free original */
66 cl_assert(git_submodule_dup(&sm_duplicate, sm) == 0);
67 git_submodule_free(sm);
68
69 /* Check duplicate */
70 cl_assert(git_submodule_owner(sm_duplicate) == g_repo);
71 cl_assert_equal_s("sm_unchanged", git_submodule_name(sm_duplicate));
72 cl_assert(git__suffixcmp(git_submodule_path(sm_duplicate), "sm_unchanged") == 0);
73 cl_assert(git__suffixcmp(git_submodule_url(sm_duplicate), "/submod2_target") == 0);
74
75 cl_assert(git_oid_streq(git_submodule_index_id(sm_duplicate), oid) == 0);
76 cl_assert(git_oid_streq(git_submodule_head_id(sm_duplicate), oid) == 0);
77 cl_assert(git_oid_streq(git_submodule_wd_id(sm_duplicate), oid) == 0);
78
79 cl_assert(git_submodule_ignore(sm_duplicate) == GIT_SUBMODULE_IGNORE_NONE);
80 cl_assert(git_submodule_update_strategy(sm_duplicate) == GIT_SUBMODULE_UPDATE_CHECKOUT);
81
82 git_submodule_free(sm_duplicate);
83}
84
aa13bf05
RB
85void test_submodule_lookup__accessors(void)
86{
87 git_submodule *sm;
88 const char *oid = "480095882d281ed676fe5b863569520e54a7d5c0";
89
90 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
91 cl_assert(git_submodule_owner(sm) == g_repo);
92 cl_assert_equal_s("sm_unchanged", git_submodule_name(sm));
93 cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
94 cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
95
9cd42358
RB
96 cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
97 cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
98 cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
aa13bf05
RB
99
100 cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
9d1f97df 101 cl_assert(git_submodule_update_strategy(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
aa13bf05 102
a15c7802
RB
103 git_submodule_free(sm);
104
105
aa13bf05
RB
106 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
107 cl_assert_equal_s("sm_changed_head", git_submodule_name(sm));
108
9cd42358
RB
109 cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
110 cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
111 cl_assert(git_oid_streq(git_submodule_wd_id(sm),
aa13bf05
RB
112 "3d9386c507f6b093471a3e324085657a3c2b4247") == 0);
113
a15c7802
RB
114 git_submodule_free(sm);
115
116
aa13bf05
RB
117 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited"));
118 cl_assert_equal_s("sm_added_and_uncommited", git_submodule_name(sm));
119
9cd42358
RB
120 cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
121 cl_assert(git_submodule_head_id(sm) == NULL);
122 cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
aa13bf05 123
a15c7802
RB
124 git_submodule_free(sm);
125
126
aa13bf05
RB
127 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits"));
128 cl_assert_equal_s("sm_missing_commits", git_submodule_name(sm));
129
9cd42358
RB
130 cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
131 cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
132 cl_assert(git_oid_streq(git_submodule_wd_id(sm),
aa13bf05 133 "5e4963595a9774b90524d35a807169049de8ccad") == 0);
a15c7802
RB
134
135 git_submodule_free(sm);
aa13bf05
RB
136}
137
138typedef struct {
139 int count;
140} sm_lookup_data;
141
142static int sm_lookup_cb(git_submodule *sm, const char *name, void *payload)
143{
144 sm_lookup_data *data = payload;
145 data->count += 1;
146 cl_assert_equal_s(git_submodule_name(sm), name);
147 return 0;
148}
149
150void test_submodule_lookup__foreach(void)
151{
a34c4f8d 152 git_config *cfg;
aa13bf05 153 sm_lookup_data data;
a34c4f8d
CMN
154
155 memset(&data, 0, sizeof(data));
156 cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
157 cl_assert_equal_i(8, data.count);
158
aa13bf05 159 memset(&data, 0, sizeof(data));
a34c4f8d
CMN
160
161 /* Change the path for a submodule so it doesn't match the name */
162 cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.gitmodules"));
163
164 cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.path", "sm_changed_index"));
165 cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.url", "../submod2_target"));
166 cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.path"));
167 cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.url"));
168
169 git_config_free(cfg);
170
aa13bf05 171 cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
fed886d9 172 cl_assert_equal_i(8, data.count);
aa13bf05 173}
1e9dd60f 174
4b3ec53c
XL
175static int foreach_cb(git_submodule *sm, const char *name, void *payload)
176{
177 GIT_UNUSED(sm);
178 GIT_UNUSED(name);
179 GIT_UNUSED(payload);
180 return 0;
181}
182
183void test_submodule_lookup__duplicated_path(void)
184{
185 cl_git_rewritefile("submod2/.gitmodules",
186 "[submodule \"sm1\"]\n"
187 " path = duplicated-path\n"
188 " url = sm1\n"
189 "[submodule \"sm2\"]\n"
190 " path = duplicated-path\n"
191 " url = sm2\n");
192
193 cl_git_fail(git_submodule_foreach(g_repo, foreach_cb, NULL));
194}
195
605da51a 196void test_submodule_lookup__lookup_even_with_unborn_head(void)
1e9dd60f 197{
605da51a 198 git_reference *head;
1e9dd60f 199
605da51a 200 /* put us on an unborn branch */
1e9dd60f 201 cl_git_pass(git_reference_symbolic_create(
659cf202 202 &head, g_repo, "HEAD", "refs/heads/garbage", 1, NULL));
605da51a 203 git_reference_free(head);
1e9dd60f 204
8061d519 205 test_submodule_lookup__simple_lookup(); /* baseline should still pass */
1e9dd60f
RB
206}
207
208void test_submodule_lookup__lookup_even_with_missing_index(void)
209{
210 git_index *idx;
1e9dd60f
RB
211
212 /* give the repo an empty index */
213 cl_git_pass(git_index_new(&idx));
214 git_repository_set_index(g_repo, idx);
215 git_index_free(idx);
216
8061d519 217 test_submodule_lookup__simple_lookup(); /* baseline should still pass */
1e9dd60f 218}
380f864a 219
aa51fa1e
CMN
220void test_submodule_lookup__backslashes(void)
221{
222 git_config *cfg;
223 git_submodule *sm;
224 git_repository *subrepo;
225 git_buf buf = GIT_BUF_INIT;
226 const char *backslashed_path = "..\\submod2_target";
227
228 cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.gitmodules"));
229 cl_git_pass(git_config_set_string(cfg, "submodule.sm_unchanged.url", backslashed_path));
230 git_config_free(cfg);
231
232 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
233 cl_assert_equal_s(backslashed_path, git_submodule_url(sm));
234 cl_git_pass(git_submodule_open(&subrepo, sm));
235
236 cl_git_pass(git_submodule_resolve_url(&buf, g_repo, backslashed_path));
237
ac3d33df 238 git_buf_dispose(&buf);
aa51fa1e
CMN
239 git_submodule_free(sm);
240 git_repository_free(subrepo);
241}
242
8f4e5275
RB
243static void baseline_tests(void)
244{
245 /* small baseline that should work even if we change the index or make
246 * commits from the index
247 */
248 assert_submodule_exists(g_repo, "sm_unchanged");
249 assert_submodule_exists(g_repo, "sm_gitmodules_only");
250 refute_submodule_exists(g_repo, "not-submodule", GIT_EEXISTS);
251}
252
253static void add_submodule_with_commit(const char *name)
254{
255 git_submodule *sm;
256 git_repository *smrepo;
257 git_index *idx;
e579e0f7 258 git_str p = GIT_STR_INIT;
8f4e5275
RB
259
260 cl_git_pass(git_submodule_add_setup(&sm, g_repo,
261 "https://github.com/libgit2/libgit2.git", name, 1));
262
263 assert_submodule_exists(g_repo, name);
264
265 cl_git_pass(git_submodule_open(&smrepo, sm));
266 cl_git_pass(git_repository_index(&idx, smrepo));
267
e579e0f7 268 cl_git_pass(git_str_joinpath(&p, git_repository_workdir(smrepo), "file"));
8f4e5275 269 cl_git_mkfile(p.ptr, "new file");
e579e0f7 270 git_str_dispose(&p);
8f4e5275
RB
271
272 cl_git_pass(git_index_add_bypath(idx, "file"));
273 cl_git_pass(git_index_write(idx));
274 git_index_free(idx);
275
276 cl_repo_commit_from_index(NULL, smrepo, NULL, 0, "initial commit");
277 git_repository_free(smrepo);
278
279 cl_git_pass(git_submodule_add_finalize(sm));
280
281 git_submodule_free(sm);
282}
283
380f864a
RB
284void test_submodule_lookup__just_added(void)
285{
286 git_submodule *sm;
e579e0f7 287 git_str snap1 = GIT_STR_INIT, snap2 = GIT_STR_INIT;
8f4e5275 288 git_reference *original_head = NULL;
8061d519
RB
289
290 refute_submodule_exists(g_repo, "sm_just_added", GIT_ENOTFOUND);
291 refute_submodule_exists(g_repo, "sm_just_added_2", GIT_ENOTFOUND);
8f4e5275
RB
292 refute_submodule_exists(g_repo, "sm_just_added_idx", GIT_ENOTFOUND);
293 refute_submodule_exists(g_repo, "sm_just_added_head", GIT_ENOTFOUND);
8061d519
RB
294 refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND);
295 refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND);
8f4e5275 296 baseline_tests();
380f864a 297
8061d519 298 cl_git_pass(git_futils_readbuffer(&snap1, "submod2/.gitmodules"));
8f4e5275 299 cl_git_pass(git_repository_head(&original_head, g_repo));
8061d519
RB
300
301 cl_git_pass(git_submodule_add_setup(&sm, g_repo,
302 "https://github.com/libgit2/libgit2.git", "sm_just_added", 1));
380f864a
RB
303 git_submodule_free(sm);
304 assert_submodule_exists(g_repo, "sm_just_added");
305
8061d519
RB
306 cl_git_pass(git_submodule_add_setup(&sm, g_repo,
307 "https://github.com/libgit2/libgit2.git", "sm_just_added_2", 1));
380f864a 308 assert_submodule_exists(g_repo, "sm_just_added_2");
8f4e5275 309 cl_git_fail(git_submodule_add_finalize(sm)); /* fails if no HEAD */
380f864a
RB
310 git_submodule_free(sm);
311
8f4e5275
RB
312 add_submodule_with_commit("sm_just_added_head");
313 cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "commit new sm to head");
314 assert_submodule_exists(g_repo, "sm_just_added_head");
315
316 add_submodule_with_commit("sm_just_added_idx");
317 assert_submodule_exists(g_repo, "sm_just_added_idx");
318
8061d519 319 cl_git_pass(git_futils_readbuffer(&snap2, "submod2/.gitmodules"));
380f864a 320
8061d519
RB
321 cl_git_append2file(
322 "submod2/.gitmodules",
323 "\n[submodule \"mismatch_name\"]\n"
324 "\tpath = mismatch_path\n"
325 "\turl = https://example.com/example.git\n\n");
380f864a
RB
326
327 assert_submodule_exists(g_repo, "mismatch_name");
328 assert_submodule_exists(g_repo, "mismatch_path");
8061d519
RB
329 assert_submodule_exists(g_repo, "sm_just_added");
330 assert_submodule_exists(g_repo, "sm_just_added_2");
8f4e5275
RB
331 assert_submodule_exists(g_repo, "sm_just_added_idx");
332 assert_submodule_exists(g_repo, "sm_just_added_head");
333 baseline_tests();
8061d519
RB
334
335 cl_git_rewritefile("submod2/.gitmodules", snap2.ptr);
e579e0f7 336 git_str_dispose(&snap2);
380f864a 337
8061d519
RB
338 refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND);
339 refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND);
380f864a
RB
340 assert_submodule_exists(g_repo, "sm_just_added");
341 assert_submodule_exists(g_repo, "sm_just_added_2");
8f4e5275
RB
342 assert_submodule_exists(g_repo, "sm_just_added_idx");
343 assert_submodule_exists(g_repo, "sm_just_added_head");
344 baseline_tests();
380f864a 345
8061d519 346 cl_git_rewritefile("submod2/.gitmodules", snap1.ptr);
e579e0f7 347 git_str_dispose(&snap1);
380f864a 348
8061d519
RB
349 refute_submodule_exists(g_repo, "mismatch_name", GIT_ENOTFOUND);
350 refute_submodule_exists(g_repo, "mismatch_path", GIT_ENOTFOUND);
351 /* note error code change, because add_setup made a repo in the workdir */
352 refute_submodule_exists(g_repo, "sm_just_added", GIT_EEXISTS);
353 refute_submodule_exists(g_repo, "sm_just_added_2", GIT_EEXISTS);
8f4e5275
RB
354 /* these still exist in index and head respectively */
355 assert_submodule_exists(g_repo, "sm_just_added_idx");
356 assert_submodule_exists(g_repo, "sm_just_added_head");
357 baseline_tests();
358
359 {
360 git_index *idx;
361 cl_git_pass(git_repository_index(&idx, g_repo));
362 cl_git_pass(git_index_remove_bypath(idx, "sm_just_added_idx"));
363 cl_git_pass(git_index_remove_bypath(idx, "sm_just_added_head"));
364 cl_git_pass(git_index_write(idx));
365 git_index_free(idx);
366 }
367
368 refute_submodule_exists(g_repo, "sm_just_added_idx", GIT_EEXISTS);
369 assert_submodule_exists(g_repo, "sm_just_added_head");
370
371 {
659cf202 372 cl_git_pass(git_reference_create(NULL, g_repo, "refs/heads/master", git_reference_target(original_head), 1, "move head back"));
8f4e5275
RB
373 git_reference_free(original_head);
374 }
375
376 refute_submodule_exists(g_repo, "sm_just_added_head", GIT_EEXISTS);
380f864a 377}
8f4e5275 378
e8e848a8
CMN
379/* Test_App and Test_App2 are fairly similar names, make sure we load the right one */
380void test_submodule_lookup__prefix_name(void)
381{
382 git_submodule *sm;
383
384 cl_git_rewritefile("submod2/.gitmodules",
385 "[submodule \"Test_App\"]\n"
386 " path = Test_App\n"
387 " url = ../Test_App\n"
388 "[submodule \"Test_App2\"]\n"
389 " path = Test_App2\n"
390 " url = ../Test_App\n");
391
392 cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App"));
393 cl_assert_equal_s("Test_App", git_submodule_name(sm));
394
395 git_submodule_free(sm);
396
397 cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App2"));
398 cl_assert_equal_s("Test_App2", git_submodule_name(sm));
399
400 git_submodule_free(sm);
401}
a3b9731f
CMN
402
403void test_submodule_lookup__renamed(void)
404{
405 const char *newpath = "sm_actually_changed";
406 git_index *idx;
407 sm_lookup_data data;
408
409 cl_git_pass(git_repository_index__weakptr(&idx, g_repo));
410
411 /* We're replicating 'git mv sm_unchanged sm_actually_changed' in this test */
412
413 cl_git_pass(p_rename("submod2/sm_unchanged", "submod2/sm_actually_changed"));
414
415 /* Change the path in .gitmodules and stage it*/
416 {
417 git_config *cfg;
418
419 cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.gitmodules"));
420 cl_git_pass(git_config_set_string(cfg, "submodule.sm_unchanged.path", newpath));
421 git_config_free(cfg);
422
423 cl_git_pass(git_index_add_bypath(idx, ".gitmodules"));
424 }
425
91f0d186 426 /* Change the worktree info in the submodule's config */
a3b9731f
CMN
427 {
428 git_config *cfg;
429
430 cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.git/modules/sm_unchanged/config"));
431 cl_git_pass(git_config_set_string(cfg, "core.worktree", "../../../sm_actually_changed"));
432 git_config_free(cfg);
433 }
434
435 /* Rename the entry in the index */
436 {
437 const git_index_entry *e;
dfe2856d 438 git_index_entry entry = {{ 0 }};
a3b9731f
CMN
439
440 e = git_index_get_bypath(idx, "sm_unchanged", 0);
441 cl_assert(e);
442 cl_assert_equal_i(GIT_FILEMODE_COMMIT, e->mode);
443
444 entry.path = newpath;
445 entry.mode = GIT_FILEMODE_COMMIT;
446 git_oid_cpy(&entry.id, &e->id);
447
448 cl_git_pass(git_index_remove(idx, "sm_unchanged", 0));
449 cl_git_pass(git_index_add(idx, &entry));
450 cl_git_pass(git_index_write(idx));
451 }
452
453 memset(&data, 0, sizeof(data));
454 cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
455 cl_assert_equal_i(8, data.count);
456}
4d99c4cf 457
eae0bfdc
PP
458void test_submodule_lookup__cached(void)
459{
4d99c4cf
BP
460 git_submodule *sm;
461 git_submodule *sm2;
462 /* See that the simple tests still pass. */
463
464 git_repository_submodule_cache_all(g_repo);
465 test_submodule_lookup__simple_lookup();
466 git_repository_submodule_cache_clear(g_repo);
467 test_submodule_lookup__simple_lookup();
468
469 /* Check that subsequent calls return different objects when cached. */
470 git_repository_submodule_cache_all(g_repo);
471 cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
472 cl_git_pass(git_submodule_lookup(&sm2, g_repo, "sm_unchanged"));
473 cl_assert_equal_p(sm, sm2);
474 git_submodule_free(sm2);
475
476 /* and that we get new objects again after clearing the cache. */
477 git_repository_submodule_cache_clear(g_repo);
478 cl_git_pass(git_submodule_lookup(&sm2, g_repo, "sm_unchanged"));
479 cl_assert(sm != sm2);
480 git_submodule_free(sm);
481 git_submodule_free(sm2);
482}
eae0bfdc
PP
483
484void test_submodule_lookup__lookup_in_bare_repository_fails(void)
485{
486 git_submodule *sm;
487
488 cl_git_sandbox_cleanup();
489 g_repo = cl_git_sandbox_init("submodules.git");
490
491 cl_git_fail(git_submodule_lookup(&sm, g_repo, "nonexisting"));
492}
493
eae0bfdc
PP
494void test_submodule_lookup__foreach_in_bare_repository_fails(void)
495{
496 cl_git_sandbox_cleanup();
497 g_repo = cl_git_sandbox_init("submodules.git");
498
499 cl_git_fail(git_submodule_foreach(g_repo, foreach_cb, NULL));
500}
4b3ec53c
XL
501
502void test_submodule_lookup__fail_invalid_gitmodules(void)
503{
504 git_submodule *sm;
505 sm_lookup_data data;
506 memset(&data, 0, sizeof(data));
507
508 cl_git_rewritefile("submod2/.gitmodules",
509 "[submodule \"Test_App\"\n"
510 " path = Test_App\n"
511 " url = ../Test_App\n");
512
513 cl_git_fail(git_submodule_lookup(&sm, g_repo, "Test_App"));
514
515 cl_git_fail(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
516}