summaryrefslogtreecommitdiff
path: root/tests/iterator
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-04-02 13:03:09 -0700
committerEdward Thomson <ethomson@github.com>2016-04-02 13:34:55 -0700
commitd47f7e1c15560e327359e69caf1bc0c41538c676 (patch)
tree519ffc682c4f054656fde2bc4a93f35d1f2845dc /tests/iterator
parent2e0391f4f1d088a9d9748a1b3bcab8ac576d63de (diff)
downloadlibgit2-d47f7e1c15560e327359e69caf1bc0c41538c676.tar.gz
iterator: support trailing `/` in start for submod
Allow callers to specify a start path with a trailing slash to match a submodule, instead of just a directory. This is for some legacy behavior that's sort of dumb, but there it is.
Diffstat (limited to 'tests/iterator')
-rw-r--r--tests/iterator/workdir.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index fc7771c20..c8f795a0d 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -1197,8 +1197,11 @@ void test_iterator_workdir__bounded_submodules(void)
git_iterator_free(i);
}
- /* Test that a submodule never matches when suffixed with a '/' */
+ /* Test that a submodule still matches when suffixed with a '/' */
{
+ const char *expected[] = { "sm_changed_head" };
+ size_t expected_len = 1;
+
git_vector_clear(&filelist);
cl_git_pass(git_vector_insert(&filelist, "sm_changed_head/"));
@@ -1207,7 +1210,7 @@ void test_iterator_workdir__bounded_submodules(void)
i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
cl_git_pass(git_iterator_for_workdir(&i, g_repo, index, head, &i_opts));
- cl_git_fail_with(GIT_ITEROVER, git_iterator_advance(NULL, i));
+ expect_iterator_items(i, expected_len, expected, expected_len, expected);
git_iterator_free(i);
}
@@ -1227,16 +1230,19 @@ void test_iterator_workdir__bounded_submodules(void)
git_iterator_free(i);
}
- /* Test that start and end do not allow '/' suffixes of submodules */
+ /* Test that start and end allow '/' suffixes of submodules */
{
- i_opts.start = "sm_changed_head/";
- i_opts.end = "sm_changed_head/";
+ const char *expected[] = { "sm_changed_head", "sm_changed_index" };
+ size_t expected_len = 2;
+
+ i_opts.start = "sm_changed_head";
+ i_opts.end = "sm_changed_index";
i_opts.pathlist.strings = NULL;
i_opts.pathlist.count = 0;
i_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE;
cl_git_pass(git_iterator_for_workdir(&i, g_repo, index, head, &i_opts));
- cl_git_fail_with(GIT_ITEROVER, git_iterator_advance(NULL, i));
+ expect_iterator_items(i, expected_len, expected, expected_len, expected);
git_iterator_free(i);
}