Commit 1cac688d by Carlos Martín Nieto

Merge pull request #3719 from libgit2/ethomson/submodule_status

WD iterator: properly identify submodules
parents 24ecf18e 4df6ddaa
...@@ -34,7 +34,7 @@ static void iterator_set_ignore_case(git_iterator *iter, bool ignore_case) ...@@ -34,7 +34,7 @@ static void iterator_set_ignore_case(git_iterator *iter, bool ignore_case)
iter->strcomp = ignore_case ? git__strcasecmp : git__strcmp; iter->strcomp = ignore_case ? git__strcasecmp : git__strcmp;
iter->strncomp = ignore_case ? git__strncasecmp : git__strncmp; iter->strncomp = ignore_case ? git__strncasecmp : git__strncmp;
iter->prefixcomp = ignore_case ? git__prefixcmp_icase : git__prefixcmp; iter->prefixcomp = ignore_case ? git__prefixcmp_icase : git__prefixcmp;
iter->entry_srch = ignore_case ? git_index_entry_srch : git_index_entry_isrch; iter->entry_srch = ignore_case ? git_index_entry_isrch : git_index_entry_srch;
git_vector_set_cmp(&iter->pathlist, (git_vector_cmp)iter->strcomp); git_vector_set_cmp(&iter->pathlist, (git_vector_cmp)iter->strcomp);
} }
......
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[submodule "One"]
url = ../submod2_target
[submodule "TWO"]
url = ../submod2_target
[submodule "three"]
url = ../submod2_target
[submodule "FoUr"]
url = ../submod2_target
[submodule "Five"]
url = ../submod2_target
[submodule "six"]
url = ../submod2_target
[submodule "sEvEn"]
url = ../submod2_target
[submodule "EIGHT"]
url = ../submod2_target
[submodule "nine"]
url = ../submod2_target
[submodule "TEN"]
url = ../submod2_target
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../EIGHT
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../Five
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../FoUr
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../One
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../TEN
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../TWO
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../nine
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../sEvEn
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../six
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../../three
[remote "origin"]
url = /tmp/libgit2_tests_5hR8uP/submod2_target
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
# pack-refs with: peeled fully-peeled
480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master
90459b51713bde15eb97852ff22c29270752b432
gitdir: ../.git/modules/EIGHT
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/Five
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/FoUr
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/One
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/TEN
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/TWO
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
[submodule "One"]
path = One
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "TWO"]
path = TWO
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "three"]
path = three
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "FoUr"]
path = FoUr
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "Five"]
path = Five
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "six"]
path = six
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "sEvEn"]
path = sEvEn
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "EIGHT"]
path = EIGHT
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "nine"]
path = nine
url = /tmp/libgit2_tests_XJLtEE/submod2_target
[submodule "TEN"]
path = TEN
url = /tmp/libgit2_tests_XJLtEE/submod2_target
gitdir: ../.git/modules/nine
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/sEvEn
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/six
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
gitdir: ../.git/modules/three
This is the target for submod2 submodule links.
Don't add commits casually because you make break tests.
This is a file to modify in submodules
It already has some history.
You can add local changes as needed.
...@@ -524,3 +524,40 @@ void test_status_submodules__entry_but_dir_tracked(void) ...@@ -524,3 +524,40 @@ void test_status_submodules__entry_but_dir_tracked(void)
git_tree_free(tree); git_tree_free(tree);
git_repository_free(repo); git_repository_free(repo);
} }
void test_status_submodules__mixed_case(void)
{
git_status_list *status;
git_status_options status_opts = GIT_STATUS_OPTIONS_INIT;
const git_status_entry *s;
size_t i;
status_opts.flags =
GIT_STATUS_OPT_INCLUDE_UNTRACKED |
GIT_STATUS_OPT_INCLUDE_IGNORED |
GIT_STATUS_OPT_INCLUDE_UNMODIFIED |
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS |
GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX |
GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR |
GIT_STATUS_OPT_RENAMES_FROM_REWRITES |
GIT_STATUS_OPT_INCLUDE_UNREADABLE |
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED;
g_repo = setup_fixture_submod3();
cl_git_pass(git_status_list_new(&status, g_repo, &status_opts));
for (i = 0; i < git_status_list_entrycount(status); i++) {
s = git_status_byindex(status, i);
if (s->head_to_index &&
strcmp(s->head_to_index->old_file.path, ".gitmodules") == 0)
continue;
cl_assert_equal_i(0, s->status);
}
git_status_list_free(status);
}
...@@ -126,6 +126,32 @@ git_repository *setup_fixture_submod2(void) ...@@ -126,6 +126,32 @@ git_repository *setup_fixture_submod2(void)
return repo; return repo;
} }
git_repository *setup_fixture_submod3(void)
{
git_repository *repo = cl_git_sandbox_init("submod3");
cl_fixture_sandbox("submod2_target");
p_rename("submod2_target/.gitted", "submod2_target/.git");
rewrite_gitmodules(git_repository_workdir(repo));
p_rename("submod3/One/.gitted", "submod3/One/.git");
p_rename("submod3/TWO/.gitted", "submod3/TWO/.git");
p_rename("submod3/three/.gitted", "submod3/three/.git");
p_rename("submod3/FoUr/.gitted", "submod3/FoUr/.git");
p_rename("submod3/Five/.gitted", "submod3/Five/.git");
p_rename("submod3/six/.gitted", "submod3/six/.git");
p_rename("submod3/sEvEn/.gitted", "submod3/sEvEn/.git");
p_rename("submod3/EIGHT/.gitted", "submod3/EIGHT/.git");
p_rename("submod3/nine/.gitted", "submod3/nine/.git");
p_rename("submod3/TEN/.gitted", "submod3/TEN/.git");
cl_set_cleanup(cleanup_fixture_submodules, "submod2_target");
cl_git_pass(git_repository_reinit_filesystem(repo, 1));
return repo;
}
git_repository *setup_fixture_super(void) git_repository *setup_fixture_super(void)
{ {
git_repository *repo = cl_git_sandbox_init("super"); git_repository *repo = cl_git_sandbox_init("super");
......
...@@ -3,6 +3,7 @@ extern void rewrite_gitmodules(const char *workdir); ...@@ -3,6 +3,7 @@ extern void rewrite_gitmodules(const char *workdir);
/* these will automatically set a cleanup callback */ /* these will automatically set a cleanup callback */
extern git_repository *setup_fixture_submodules(void); extern git_repository *setup_fixture_submodules(void);
extern git_repository *setup_fixture_submod2(void); extern git_repository *setup_fixture_submod2(void);
extern git_repository *setup_fixture_submod3(void);
extern git_repository *setup_fixture_submodule_simple(void); extern git_repository *setup_fixture_submodule_simple(void);
extern git_repository *setup_fixture_super(void); extern git_repository *setup_fixture_super(void);
extern git_repository *setup_fixture_submodule_with_path(void); extern git_repository *setup_fixture_submodule_with_path(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment