summaryrefslogtreecommitdiff
path: root/tests-clar
diff options
context:
space:
mode:
authoryorah <yoram.harmelin@gmail.com>2012-07-23 18:16:09 +0200
committeryorah <yoram.harmelin@gmail.com>2012-07-24 14:03:09 +0200
commita1773f9d89887d299248d15b43953d3fa494a025 (patch)
tree4b204fca95ff0e11766eb3d570c919874d9908db /tests-clar
parentffbc689c8768c66cddf9ef3ab6c88c41ecf4c1ab (diff)
downloadlibgit2-a1773f9d89887d299248d15b43953d3fa494a025.tar.gz
Add flag to turn off pathspec testing for diff and status
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/status/worktree.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 1bdd8160a..bd57cf2b6 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -726,3 +726,49 @@ void test_status_worktree__filemode_changes(void)
git_config_free(cfg);
}
+
+int cb_status__expected_path(const char *p, unsigned int s, void *payload)
+{
+ const char *expected_path = (const char *)payload;
+
+ GIT_UNUSED(s);
+
+ if (payload == NULL)
+ cl_fail("Unexpected path");
+
+ cl_assert_equal_s(expected_path, p);
+
+ return 0;
+}
+
+void test_status_worktree__disable_pathspec_match(void)
+{
+ git_repository *repo;
+ git_status_options opts;
+ char *file_with_bracket = "LICENSE[1].md",
+ *imaginary_file_with_bracket = "LICENSE[1-2].md";
+
+ cl_git_pass(git_repository_init(&repo, "pathspec", 0));
+ cl_git_mkfile("pathspec/LICENSE[1].md", "screaming bracket\n");
+ cl_git_mkfile("pathspec/LICENSE1.md", "no bracket\n");
+
+ memset(&opts, 0, sizeof(opts));
+ opts.flags = GIT_STATUS_OPT_INCLUDE_UNTRACKED |
+ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH;
+ opts.pathspec.count = 1;
+ opts.pathspec.strings = &file_with_bracket;
+
+ cl_git_pass(
+ git_status_foreach_ext(repo, &opts, cb_status__expected_path,
+ file_with_bracket)
+ );
+
+ /* Test passing a pathspec matching files in the workdir. */
+ /* Must not match because pathspecs are disabled. */
+ opts.pathspec.strings = &imaginary_file_with_bracket;
+ cl_git_pass(
+ git_status_foreach_ext(repo, &opts, cb_status__expected_path, NULL)
+ );
+
+ git_repository_free(repo);
+}