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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libgit2/submodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static void free_submodule_names(git_strmap *names)
*/
static int load_submodule_names(git_strmap **out, git_repository *repo, git_config *cfg)
{
const char *key = "submodule\\..*\\.path";
const char *key = "^submodule\\..*\\.path$";
git_config_iterator *iter = NULL;
git_config_entry *entry;
git_str buf = GIT_STR_INIT;
Expand Down Expand Up @@ -332,7 +332,7 @@ int git_submodule__lookup_with_cache(
/* If it's not configured or we're looking by path */
if (location == 0 || location == GIT_SUBMODULE_STATUS_IN_WD) {
git_config_backend *mods;
const char *pattern = "submodule\\..*\\.path";
const char *pattern = "^submodule\\..*\\.path$";
git_str path = GIT_STR_INIT;
fbp_data data = { NULL, NULL };

Expand Down
18 changes: 18 additions & 0 deletions tests/libgit2/submodule/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,24 @@ void test_submodule_lookup__prefix_name(void)
git_submodule_free(sm);
}

/* ".path" in name of submodule */
void test_submodule_lookup__dotpath_in_name(void)
{
sm_lookup_data data;

cl_git_rewritefile(
"submod2/.gitmodules", "[submodule \"kwb.pathdict\"]\n"
" path = kwb.pathdict\n"
" url = ../Test_App\n"
"[submodule \"fakin.path.app\"]\n"
" path = fakin.path.app\n"
" url = ../Test_App\n");

memset(&data, 0, sizeof(data));
cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
cl_assert_equal_i(9, data.count);
}

void test_submodule_lookup__renamed(void)
{
const char *newpath = "sm_actually_changed";
Expand Down