diff options
Diffstat (limited to 'tests')
23 files changed, 69 insertions, 0 deletions
diff --git a/tests/repo/reservedname.c b/tests/repo/reservedname.c index faea0cc2b..2a5b38239 100644 --- a/tests/repo/reservedname.c +++ b/tests/repo/reservedname.c @@ -106,3 +106,27 @@ void test_repo_reservedname__submodule_pointer(void) git_repository_free(sub_repo); #endif } + +/* Like the `submodule_pointer` test (above), this ensures that we do not + * follow the gitlink to the submodule's repository location and treat that + * as a reserved name. This tests at an initial submodule update, where the + * submodule repo is being created. + */ +void test_repo_reservedname__submodule_pointer_during_create(void) +{ + git_repository *repo; + git_submodule *sm; + git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; + git_buf url = GIT_BUF_INIT; + + repo = setup_fixture_super(); + + cl_git_pass(git_buf_joinpath(&url, clar_sandbox_path(), "sub.git")); + cl_repo_set_string(repo, "submodule.sub.url", url.ptr); + + cl_git_pass(git_submodule_lookup(&sm, repo, "sub")); + cl_git_pass(git_submodule_update(sm, 1, &update_options)); + + git_submodule_free(sm); + git_buf_free(&url); +} diff --git a/tests/resources/sub.git/HEAD b/tests/resources/sub.git/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests/resources/sub.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests/resources/sub.git/config b/tests/resources/sub.git/config new file mode 100644 index 000000000..78387c50b --- /dev/null +++ b/tests/resources/sub.git/config @@ -0,0 +1,8 @@ +[core] + repositoryformatversion = 0 + filemode = false + bare = false + logallrefupdates = true + symlinks = false + ignorecase = true + hideDotFiles = dotGitOnly diff --git a/tests/resources/sub.git/index b/tests/resources/sub.git/index Binary files differnew file mode 100644 index 000000000..54be69e33 --- /dev/null +++ b/tests/resources/sub.git/index diff --git a/tests/resources/sub.git/logs/HEAD b/tests/resources/sub.git/logs/HEAD new file mode 100644 index 000000000..f636268f6 --- /dev/null +++ b/tests/resources/sub.git/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision diff --git a/tests/resources/sub.git/logs/refs/heads/master b/tests/resources/sub.git/logs/refs/heads/master new file mode 100644 index 000000000..f636268f6 --- /dev/null +++ b/tests/resources/sub.git/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision diff --git a/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d b/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d Binary files differnew file mode 100644 index 000000000..a095b3fb8 --- /dev/null +++ b/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d diff --git a/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623 b/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623 Binary files differnew file mode 100644 index 000000000..ef8316670 --- /dev/null +++ b/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623 diff --git a/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb b/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb Binary files differnew file mode 100644 index 000000000..9adc11d71 --- /dev/null +++ b/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb diff --git a/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 b/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Binary files differnew file mode 100644 index 000000000..221b55de7 --- /dev/null +++ b/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 diff --git a/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 b/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 Binary files differnew file mode 100644 index 000000000..d9bb9c84d --- /dev/null +++ b/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 diff --git a/tests/resources/sub.git/refs/heads/master b/tests/resources/sub.git/refs/heads/master new file mode 100644 index 000000000..0e4d6e2a7 --- /dev/null +++ b/tests/resources/sub.git/refs/heads/master @@ -0,0 +1 @@ +b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 diff --git a/tests/resources/super/.gitted/COMMIT_EDITMSG b/tests/resources/super/.gitted/COMMIT_EDITMSG new file mode 100644 index 000000000..e2d6b8987 --- /dev/null +++ b/tests/resources/super/.gitted/COMMIT_EDITMSG @@ -0,0 +1 @@ +submodule diff --git a/tests/resources/super/.gitted/HEAD b/tests/resources/super/.gitted/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests/resources/super/.gitted/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests/resources/super/.gitted/config b/tests/resources/super/.gitted/config new file mode 100644 index 000000000..06a8b7790 --- /dev/null +++ b/tests/resources/super/.gitted/config @@ -0,0 +1,10 @@ +[core] + repositoryformatversion = 0 + filemode = false + bare = false + logallrefupdates = true + symlinks = false + ignorecase = true + hideDotFiles = dotGitOnly +[submodule "sub"] + url = ../sub.git diff --git a/tests/resources/super/.gitted/index b/tests/resources/super/.gitted/index Binary files differnew file mode 100644 index 000000000..cc2ffffb9 --- /dev/null +++ b/tests/resources/super/.gitted/index diff --git a/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 b/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 Binary files differnew file mode 100644 index 000000000..727d3a696 --- /dev/null +++ b/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 diff --git a/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 b/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 Binary files differnew file mode 100644 index 000000000..7fd889d5f --- /dev/null +++ b/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 diff --git a/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034 b/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034 Binary files differnew file mode 100644 index 000000000..f26c68c54 --- /dev/null +++ b/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034 diff --git a/tests/resources/super/.gitted/refs/heads/master b/tests/resources/super/.gitted/refs/heads/master new file mode 100644 index 000000000..663a9dcd9 --- /dev/null +++ b/tests/resources/super/.gitted/refs/heads/master @@ -0,0 +1 @@ +79d0d58ca6aa1688a073d280169908454cad5b91 diff --git a/tests/resources/super/gitmodules b/tests/resources/super/gitmodules new file mode 100644 index 000000000..a3d8f7f5a --- /dev/null +++ b/tests/resources/super/gitmodules @@ -0,0 +1,3 @@ +[submodule "sub"] + path = sub + url = ../sub.git diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c index 1dc687231..cde69d92d 100644 --- a/tests/submodule/submodule_helpers.c +++ b/tests/submodule/submodule_helpers.c @@ -126,6 +126,22 @@ git_repository *setup_fixture_submod2(void) return repo; } +git_repository *setup_fixture_super(void) +{ + git_repository *repo = cl_git_sandbox_init("super"); + + cl_fixture_sandbox("sub.git"); + p_mkdir("super/sub", 0777); + + rewrite_gitmodules(git_repository_workdir(repo)); + + cl_set_cleanup(cleanup_fixture_submodules, "sub.git"); + + cl_git_pass(git_repository_reinit_filesystem(repo, 1)); + + return repo; +} + git_repository *setup_fixture_submodule_simple(void) { git_repository *repo = cl_git_sandbox_init("submodule_simple"); diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h index 1493f245f..1191ab35b 100644 --- a/tests/submodule/submodule_helpers.h +++ b/tests/submodule/submodule_helpers.h @@ -4,6 +4,7 @@ extern void rewrite_gitmodules(const char *workdir); extern git_repository *setup_fixture_submodules(void); extern git_repository *setup_fixture_submod2(void); extern git_repository *setup_fixture_submodule_simple(void); +extern git_repository *setup_fixture_super(void); extern unsigned int get_submodule_status(git_repository *, const char *); |