|
1 | 1 | #include "clar_libgit2.h"
|
2 | 2 | #include "submodule_helpers.h"
|
3 | 3 | #include "git2/sys/repository.h"
|
| 4 | +#include "repository.h" |
4 | 5 | #include "fileops.h"
|
5 | 6 |
|
6 | 7 | static git_repository *g_repo = NULL;
|
@@ -103,8 +104,25 @@ static int sm_lookup_cb(git_submodule *sm, const char *name, void *payload)
|
103 | 104 |
|
104 | 105 | void test_submodule_lookup__foreach(void)
|
105 | 106 | {
|
| 107 | + git_config *cfg; |
106 | 108 | 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 | + |
107 | 114 | 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 | + |
108 | 126 | cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
|
109 | 127 | cl_assert_equal_i(8, data.count);
|
110 | 128 | }
|
|
0 commit comments