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

Skip to content

Commit 1207b8f

Browse files
committed
submdule: reproduce double-reporting of a submodule in foreach
When we rename a submodule, we should be merging two sets of information based on whether their path is the same. We currently only deduplicate on equal name, which causes us to double-report.
1 parent f2dc6b7 commit 1207b8f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/submodule/lookup.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "clar_libgit2.h"
22
#include "submodule_helpers.h"
33
#include "git2/sys/repository.h"
4+
#include "repository.h"
45
#include "fileops.h"
56

67
static git_repository *g_repo = NULL;
@@ -103,8 +104,25 @@ static int sm_lookup_cb(git_submodule *sm, const char *name, void *payload)
103104

104105
void test_submodule_lookup__foreach(void)
105106
{
107+
git_config *cfg;
106108
sm_lookup_data data;
109+
110+
memset(&data, 0, sizeof(data));
111+
cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
112+
cl_assert_equal_i(8, data.count);
113+
107114
memset(&data, 0, sizeof(data));
115+
116+
/* Change the path for a submodule so it doesn't match the name */
117+
cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.gitmodules"));
118+
119+
cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.path", "sm_changed_index"));
120+
cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.url", "../submod2_target"));
121+
cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.path"));
122+
cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.url"));
123+
124+
git_config_free(cfg);
125+
108126
cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
109127
cl_assert_equal_i(8, data.count);
110128
}

0 commit comments

Comments
 (0)