Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-08-31 00:06:26 +0300
committerEdward Thomson <ethomson@edwardthomson.com>2015-08-31 00:06:26 +0300
commit4a0dbeb0d35343ded24b51906f2a8f8ef6c7910b (patch)
tree2ccbd7c102ff4e4aa2b0b63469a77832b0e276dd /tests/diff
parent3273ab3f0b04d673b9515b149674d5716939d9a5 (diff)
diff: use new iterator pathlist handling
When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH` turn on the faster iterator pathlist handling. Updates iterator pathspecs to include directory prefixes (eg, `foo/`) for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
Diffstat (limited to 'tests/diff')
-rw-r--r--tests/diff/workdir.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c
index 503d67450..336f959f6 100644
--- a/tests/diff/workdir.c
+++ b/tests/diff/workdir.c
@@ -486,7 +486,7 @@ void test_diff_workdir__to_index_with_pathlist_disabling_fnmatch(void)
/* ensure that a single NULL pathspec is filtered out (like when using
* fnmatch filtering)
*/
- opts.pathspec.strings = &pathspec;
+
opts.pathspec.count = 1;
cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
@@ -581,6 +581,30 @@ void test_diff_workdir__to_index_with_pathlist_disabling_fnmatch(void)
git_diff_free(diff);
+ /* ensure that multiple trailing slashes are ignored */
+ pathspec = "subdir//////";
+
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
+
+ for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
+ memset(&exp, 0, sizeof(exp));
+
+ if (use_iterator)
+ cl_git_pass(diff_foreach_via_iterator(
+ diff, diff_file_cb, NULL, NULL, NULL, &exp));
+ else
+ cl_git_pass(git_diff_foreach(diff, diff_file_cb, NULL, NULL, NULL, &exp));
+
+ cl_assert_equal_i(3, exp.files);
+ cl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_MODIFIED]);
+ cl_assert_equal_i(0, exp.file_status[GIT_DELTA_IGNORED]);
+ cl_assert_equal_i(1, exp.file_status[GIT_DELTA_UNTRACKED]);
+ }
+
+ git_diff_free(diff);
+
/* ensure that fnmatching is completely disabled */
pathspec = "subdir/*";