Blame tests/repo/pathspec.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
#include "git2/pathspec.h"
Packit Service 20376f
Packit Service 20376f
static git_repository *g_repo;
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__initialize(void)
Packit Service 20376f
{
Packit Service 20376f
	g_repo = cl_git_sandbox_init("status");
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__cleanup(void)
Packit Service 20376f
{
Packit Service 20376f
	cl_git_sandbox_cleanup();
Packit Service 20376f
	g_repo = NULL;
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
static char *str0[] = { "*_file", "new_file", "garbage" };
Packit Service 20376f
static char *str1[] = { "*_FILE", "NEW_FILE", "GARBAGE" };
Packit Service 20376f
static char *str2[] = { "staged_*" };
Packit Service 20376f
static char *str3[] = { "!subdir", "*_file", "new_file" };
Packit Service 20376f
static char *str4[] = { "*" };
Packit Service 20376f
static char *str5[] = { "S*" };
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__workdir0(void)
Packit Service 20376f
{
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "*_file", "new_file", "garbage" } */
Packit Service 20376f
	s.strings = str0; s.count = ARRAY_SIZE(str0);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
Packit Service 20376f
	cl_assert_equal_sz(10, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(10, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 0));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES | GIT_PATHSPEC_FAILURES_ONLY, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__workdir1(void)
Packit Service 20376f
{
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "*_FILE", "NEW_FILE", "GARBAGE" } */
Packit Service 20376f
	s.strings = str1; s.count = ARRAY_SIZE(str1);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_IGNORE_CASE, ps));
Packit Service 20376f
	cl_assert_equal_sz(10, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_fail(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE | GIT_PATHSPEC_NO_MATCH_ERROR, ps));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_IGNORE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(10, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(3, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__workdir2(void)
Packit Service 20376f
{
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "staged_*" } */
Packit Service 20376f
	s.strings = str2; s.count = ARRAY_SIZE(str2);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
Packit Service 20376f
	cl_assert_equal_sz(5, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(5, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_fail(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_NO_GLOB | GIT_PATHSPEC_NO_MATCH_ERROR, ps));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_NO_GLOB | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__workdir3(void)
Packit Service 20376f
{
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "!subdir", "*_file", "new_file" } */
Packit Service 20376f
	s.strings = str3; s.count = ARRAY_SIZE(str3);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
Packit Service 20376f
	cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
Packit Service 20376f
	cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s("new_file", git_pathspec_match_list_entry(m, 2));
Packit Service 20376f
	cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 3));
Packit Service 20376f
	cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 4));
Packit Service 20376f
	cl_assert_equal_s("staged_new_file", git_pathspec_match_list_entry(m, 5));
Packit Service 20376f
	cl_assert_equal_s("staged_new_file_modified_file", git_pathspec_match_list_entry(m, 6));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 7));
Packit Service 20376f
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__workdir4(void)
Packit Service 20376f
{
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "*" } */
Packit Service 20376f
	s.strings = str4; s.count = ARRAY_SIZE(str4);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_workdir(&m, g_repo, 0, ps));
Packit Service 20376f
	cl_assert_equal_sz(13, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("\xE8\xBF\x99", git_pathspec_match_list_entry(m, 12));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__index0(void)
Packit Service 20376f
{
Packit Service 20376f
	git_index *idx;
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_repository_index(&idx, g_repo));
Packit Service 20376f
Packit Service 20376f
	/* { "*_file", "new_file", "garbage" } */
Packit Service 20376f
	s.strings = str0; s.count = ARRAY_SIZE(str0);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_index(&m, idx, 0, ps));
Packit Service 20376f
	cl_assert_equal_sz(9, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 2));
Packit Service 20376f
	cl_assert_equal_s("staged_new_file", git_pathspec_match_list_entry(m, 3));
Packit Service 20376f
	cl_assert_equal_s("staged_new_file_deleted_file", git_pathspec_match_list_entry(m, 4));
Packit Service 20376f
	cl_assert_equal_s("staged_new_file_modified_file", git_pathspec_match_list_entry(m, 5));
Packit Service 20376f
	cl_assert_equal_s("subdir/current_file", git_pathspec_match_list_entry(m, 6));
Packit Service 20376f
	cl_assert_equal_s("subdir/deleted_file", git_pathspec_match_list_entry(m, 7));
Packit Service 20376f
	cl_assert_equal_s("subdir/modified_file", git_pathspec_match_list_entry(m, 8));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 9));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_index(&m, idx,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(9, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("new_file", git_pathspec_match_list_failed_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_failed_entry(m, 2));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
	git_index_free(idx);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__index1(void)
Packit Service 20376f
{
Packit Service 20376f
	/* Currently the USE_CASE and IGNORE_CASE flags don't work on the
Packit Service 20376f
	 * index because the index sort order for the index iterator is
Packit Service 20376f
	 * set by the index itself.  I think the correct fix is for the
Packit Service 20376f
	 * index not to embed a global sort order but to support traversal
Packit Service 20376f
	 * in either case sensitive or insensitive order in a stateless
Packit Service 20376f
	 * manner.
Packit Service 20376f
	 *
Packit Service 20376f
	 * Anyhow, as it is, there is no point in doing this test.
Packit Service 20376f
	 */
Packit Service 20376f
#if 0
Packit Service 20376f
	git_index *idx;
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_repository_index(&idx, g_repo));
Packit Service 20376f
Packit Service 20376f
	/* { "*_FILE", "NEW_FILE", "GARBAGE" } */
Packit Service 20376f
	s.strings = str1; s.count = ARRAY_SIZE(str1);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_index(&m, idx,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_index(&m, idx,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(3, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_index(&m, idx,
Packit Service 20376f
		GIT_PATHSPEC_IGNORE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(10, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
	git_index_free(idx);
Packit Service 20376f
#endif
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__tree0(void)
Packit Service 20376f
{
Packit Service 20376f
	git_object *tree;
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "*_file", "new_file", "garbage" } */
Packit Service 20376f
	s.strings = str0; s.count = ARRAY_SIZE(str0);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD~2^{tree}"));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(4, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 2));
Packit Service 20376f
	cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 3));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 4));
Packit Service 20376f
	cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("new_file", git_pathspec_match_list_failed_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_failed_entry(m, 2));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_object_free(tree);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD^{tree}"));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
Packit Service 20376f
		GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(7, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("current_file", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("modified_file", git_pathspec_match_list_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s("staged_changes_modified_file", git_pathspec_match_list_entry(m, 2));
Packit Service 20376f
	cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 3));
Packit Service 20376f
	cl_assert_equal_s("subdir/current_file", git_pathspec_match_list_entry(m, 4));
Packit Service 20376f
	cl_assert_equal_s("subdir/deleted_file", git_pathspec_match_list_entry(m, 5));
Packit Service 20376f
	cl_assert_equal_s("subdir/modified_file", git_pathspec_match_list_entry(m, 6));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_entry(m, 7));
Packit Service 20376f
	cl_assert_equal_sz(2, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("new_file", git_pathspec_match_list_failed_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("garbage", git_pathspec_match_list_failed_entry(m, 1));
Packit Service 20376f
	cl_assert_equal_s(NULL, git_pathspec_match_list_failed_entry(m, 2));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_object_free(tree);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__tree5(void)
Packit Service 20376f
{
Packit Service 20376f
	git_object *tree;
Packit Service 20376f
	git_strarray s;
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
	git_pathspec_match_list *m;
Packit Service 20376f
Packit Service 20376f
	/* { "S*" } */
Packit Service 20376f
	s.strings = str5; s.count = ARRAY_SIZE(str5);
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD~2^{tree}"));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
Packit Service 20376f
		GIT_PATHSPEC_USE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_sz(1, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
Packit Service 20376f
		GIT_PATHSPEC_IGNORE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(5, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("staged_changes", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("staged_delete_modified_file", git_pathspec_match_list_entry(m, 4));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_object_free(tree);
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_revparse_single(&tree, g_repo, "HEAD^{tree}"));
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_match_tree(&m, (git_tree *)tree,
Packit Service 20376f
		GIT_PATHSPEC_IGNORE_CASE | GIT_PATHSPEC_FIND_FAILURES, ps));
Packit Service 20376f
	cl_assert_equal_sz(9, git_pathspec_match_list_entrycount(m));
Packit Service 20376f
	cl_assert_equal_s("staged_changes", git_pathspec_match_list_entry(m, 0));
Packit Service 20376f
	cl_assert_equal_s("subdir.txt", git_pathspec_match_list_entry(m, 5));
Packit Service 20376f
	cl_assert_equal_s("subdir/current_file", git_pathspec_match_list_entry(m, 6));
Packit Service 20376f
	cl_assert_equal_sz(0, git_pathspec_match_list_failed_entrycount(m));
Packit Service 20376f
	git_pathspec_match_list_free(m);
Packit Service 20376f
Packit Service 20376f
	git_object_free(tree);
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_repo_pathspec__in_memory(void)
Packit Service 20376f
{
Packit Service 20376f
	static char *strings[] = { "one", "two*", "!three*", "*four" };
Packit Service 20376f
	git_strarray s = { strings, ARRAY_SIZE(strings) };
Packit Service 20376f
	git_pathspec *ps;
Packit Service 20376f
Packit Service 20376f
	cl_git_pass(git_pathspec_new(&ps, &s);;
Packit Service 20376f
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, 0, "one"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, 0, "ONE"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, GIT_PATHSPEC_IGNORE_CASE, "ONE"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, 0, "two"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, 0, "two.txt"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, 0, "three.txt"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, 0, "anything.four"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, 0, "three.four"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, 0, "nomatch"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, GIT_PATHSPEC_NO_GLOB, "two"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, GIT_PATHSPEC_NO_GLOB, "two*"));
Packit Service 20376f
	cl_assert(!git_pathspec_matches_path(ps, GIT_PATHSPEC_NO_GLOB, "anyfour"));
Packit Service 20376f
	cl_assert(git_pathspec_matches_path(ps, GIT_PATHSPEC_NO_GLOB, "*four"));
Packit Service 20376f
Packit Service 20376f
	git_pathspec_free(ps);
Packit Service 20376f
}