Commit e8e848a8 by Carlos Martín Nieto

submodule: add failing test for loading the wrong submodule

When two submodules are fairly similar, we may end up loading the wrong
one.
parent bf7d2761
...@@ -269,3 +269,26 @@ void test_submodule_lookup__just_added(void) ...@@ -269,3 +269,26 @@ void test_submodule_lookup__just_added(void)
refute_submodule_exists(g_repo, "sm_just_added_head", GIT_EEXISTS); refute_submodule_exists(g_repo, "sm_just_added_head", GIT_EEXISTS);
} }
/* Test_App and Test_App2 are fairly similar names, make sure we load the right one */
void test_submodule_lookup__prefix_name(void)
{
git_submodule *sm;
cl_git_rewritefile("submod2/.gitmodules",
"[submodule \"Test_App\"]\n"
" path = Test_App\n"
" url = ../Test_App\n"
"[submodule \"Test_App2\"]\n"
" path = Test_App2\n"
" url = ../Test_App\n");
cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App"));
cl_assert_equal_s("Test_App", git_submodule_name(sm));
git_submodule_free(sm);
cl_git_pass(git_submodule_lookup(&sm, g_repo, "Test_App2"));
cl_assert_equal_s("Test_App2", git_submodule_name(sm));
git_submodule_free(sm);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment