summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-07-11 13:32:57 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-07-11 13:32:57 +0200
commita34c4f8dcee7e985444be9f5e02b627a55c16bbb (patch)
treeab2030fa5380d9cf0b0c10d8eb00b6bc96c8716e
parenta0bdfe32412b687910e809cced2d31d1e76918fe (diff)
downloadlibgit2-a34c4f8dcee7e985444be9f5e02b627a55c16bbb.tar.gz
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.
-rw-r--r--tests/submodule/lookup.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c
index 4d40e2279..9b2b3aa19 100644
--- a/tests/submodule/lookup.c
+++ b/tests/submodule/lookup.c
@@ -1,6 +1,7 @@
#include "clar_libgit2.h"
#include "submodule_helpers.h"
#include "git2/sys/repository.h"
+#include "repository.h"
#include "fileops.h"
static git_repository *g_repo = NULL;
@@ -103,8 +104,25 @@ static int sm_lookup_cb(git_submodule *sm, const char *name, void *payload)
void test_submodule_lookup__foreach(void)
{
+ git_config *cfg;
sm_lookup_data data;
+
+ memset(&data, 0, sizeof(data));
+ cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
+ cl_assert_equal_i(8, data.count);
+
memset(&data, 0, sizeof(data));
+
+ /* Change the path for a submodule so it doesn't match the name */
+ cl_git_pass(git_config_open_ondisk(&cfg, "submod2/.gitmodules"));
+
+ cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.path", "sm_changed_index"));
+ cl_git_pass(git_config_set_string(cfg, "submodule.smchangedindex.url", "../submod2_target"));
+ cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.path"));
+ cl_git_pass(git_config_delete_entry(cfg, "submodule.sm_changed_index.url"));
+
+ git_config_free(cfg);
+
cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
cl_assert_equal_i(8, data.count);
}