Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8e848a

Browse files
committed
submodule: add failing test for loading the wrong submodule
When two submodules are fairly similar, we may end up loading the wrong one.
1 parent bf7d276 commit e8e848a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/submodule/lookup.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,26 @@ void test_submodule_lookup__just_added(void)
269269
refute_submodule_exists(g_repo, "sm_just_added_head", GIT_EEXISTS);
270270
}
271271

272+
/* Test_App and Test_App2 are fairly similar names, make sure we load the right one */
273+
void test_submodule_lookup__prefix_name(void)
274+
{
275+
git_submodule *sm;
276+
277+
cl_git_rewritefile("submod2/.gitmodules",
278+
"[submodule \"Test_App\"]\n"
279+
" path = Test_App\n"
280+
" url = ../Test_App\n"
281+
"[submodule \"Test_App2\"]\n"
282+
" path = Test_App2\n"
283+
" url = ../Test_App\n");
284+
285+
cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App"));
286+
cl_assert_equal_s("Test_App", git_submodule_name(sm));
287+
288+
git_submodule_free(sm);
289+
290+
cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App2"));
291+
cl_assert_equal_s("Test_App2", git_submodule_name(sm));
292+
293+
git_submodule_free(sm);
294+
}

0 commit comments

Comments
 (0)