Blame tests/repo/pathspec.c

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