mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
repo::reservedname: test a submodule update
Test an initial submodule update, where we are trying to checkout the submodule for the first time, and placing a file within the submodule working directory with the same name as the submodule (and consequently, the same name as the repository itself).
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
1
tests/resources/sub.git/HEAD
Normal file
1
tests/resources/sub.git/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
8
tests/resources/sub.git/config
Normal file
8
tests/resources/sub.git/config
Normal file
@@ -0,0 +1,8 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = false
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
symlinks = false
|
||||
ignorecase = true
|
||||
hideDotFiles = dotGitOnly
|
||||
BIN
tests/resources/sub.git/index
Normal file
BIN
tests/resources/sub.git/index
Normal file
Binary file not shown.
1
tests/resources/sub.git/logs/HEAD
Normal file
1
tests/resources/sub.git/logs/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision
|
||||
1
tests/resources/sub.git/logs/refs/heads/master
Normal file
1
tests/resources/sub.git/logs/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
tests/resources/sub.git/refs/heads/master
Normal file
1
tests/resources/sub.git/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8
|
||||
1
tests/resources/super/.gitted/COMMIT_EDITMSG
Normal file
1
tests/resources/super/.gitted/COMMIT_EDITMSG
Normal file
@@ -0,0 +1 @@
|
||||
submodule
|
||||
1
tests/resources/super/.gitted/HEAD
Normal file
1
tests/resources/super/.gitted/HEAD
Normal file
@@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
||||
10
tests/resources/super/.gitted/config
Normal file
10
tests/resources/super/.gitted/config
Normal file
@@ -0,0 +1,10 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = false
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
symlinks = false
|
||||
ignorecase = true
|
||||
hideDotFiles = dotGitOnly
|
||||
[submodule "sub"]
|
||||
url = ../sub.git
|
||||
BIN
tests/resources/super/.gitted/index
Normal file
BIN
tests/resources/super/.gitted/index
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
tests/resources/super/.gitted/refs/heads/master
Normal file
1
tests/resources/super/.gitted/refs/heads/master
Normal file
@@ -0,0 +1 @@
|
||||
79d0d58ca6aa1688a073d280169908454cad5b91
|
||||
3
tests/resources/super/gitmodules
Normal file
3
tests/resources/super/gitmodules
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "sub"]
|
||||
path = sub
|
||||
url = ../sub.git
|
||||
@@ -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");
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user