Blame tests/path/dotgit.c

Packit Service 20376f
#include "clar_libgit2.h"
Packit Service 20376f
#include "path.h"
Packit Service 20376f
Packit Service 20376f
static char *gitmodules_altnames[] = {
Packit Service 20376f
	".gitmodules",
Packit Service 20376f
Packit Service 20376f
	/*
Packit Service 20376f
	 * Equivalent to the ".git\u200cmodules" string from git but hard-coded
Packit Service 20376f
	 * as a UTF-8 sequence
Packit Service 20376f
	 */
Packit Service 20376f
	".git\xe2\x80\x8cmodules",
Packit Service 20376f
Packit Service 20376f
	".Gitmodules",
Packit Service 20376f
	".gitmoduleS",
Packit Service 20376f
Packit Service 20376f
	".gitmodules ",
Packit Service 20376f
	".gitmodules.",
Packit Service 20376f
	".gitmodules  ",
Packit Service 20376f
	".gitmodules. ",
Packit Service 20376f
	".gitmodules .",
Packit Service 20376f
	".gitmodules..",
Packit Service 20376f
	".gitmodules   ",
Packit Service 20376f
	".gitmodules.  ",
Packit Service 20376f
	".gitmodules . ",
Packit Service 20376f
	".gitmodules  .",
Packit Service 20376f
Packit Service 20376f
	".Gitmodules ",
Packit Service 20376f
	".Gitmodules.",
Packit Service 20376f
	".Gitmodules  ",
Packit Service 20376f
	".Gitmodules. ",
Packit Service 20376f
	".Gitmodules .",
Packit Service 20376f
	".Gitmodules..",
Packit Service 20376f
	".Gitmodules   ",
Packit Service 20376f
	".Gitmodules.  ",
Packit Service 20376f
	".Gitmodules . ",
Packit Service 20376f
	".Gitmodules  .",
Packit Service 20376f
Packit Service 20376f
	"GITMOD~1",
Packit Service 20376f
	"gitmod~1",
Packit Service 20376f
	"GITMOD~2",
Packit Service 20376f
	"gitmod~3",
Packit Service 20376f
	"GITMOD~4",
Packit Service 20376f
Packit Service 20376f
	"GITMOD~1 ",
Packit Service 20376f
	"gitmod~2.",
Packit Service 20376f
	"GITMOD~3  ",
Packit Service 20376f
	"gitmod~4. ",
Packit Service 20376f
	"GITMOD~1 .",
Packit Service 20376f
	"gitmod~2   ",
Packit Service 20376f
	"GITMOD~3.  ",
Packit Service 20376f
	"gitmod~4 . ",
Packit Service 20376f
Packit Service 20376f
	"GI7EBA~1",
Packit Service 20376f
	"gi7eba~9",
Packit Service 20376f
Packit Service 20376f
	"GI7EB~10",
Packit Service 20376f
	"GI7EB~11",
Packit Service 20376f
	"GI7EB~99",
Packit Service 20376f
	"GI7EB~10",
Packit Service 20376f
	"GI7E~100",
Packit Service 20376f
	"GI7E~101",
Packit Service 20376f
	"GI7E~999",
Packit Service 20376f
	"~1000000",
Packit Service 20376f
	"~9999999",
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
static char *gitmodules_not_altnames[] = {
Packit Service 20376f
	".gitmodules x",
Packit Service 20376f
	".gitmodules .x",
Packit Service 20376f
Packit Service 20376f
	" .gitmodules",
Packit Service 20376f
Packit Service 20376f
	"..gitmodules",
Packit Service 20376f
Packit Service 20376f
	"gitmodules",
Packit Service 20376f
Packit Service 20376f
	".gitmodule",
Packit Service 20376f
Packit Service 20376f
	".gitmodules x ",
Packit Service 20376f
	".gitmodules .x",
Packit Service 20376f
Packit Service 20376f
	"GI7EBA~",
Packit Service 20376f
	"GI7EBA~0",
Packit Service 20376f
	"GI7EBA~~1",
Packit Service 20376f
	"GI7EBA~X",
Packit Service 20376f
	"Gx7EBA~1",
Packit Service 20376f
	"GI7EBX~1",
Packit Service 20376f
Packit Service 20376f
	"GI7EB~1",
Packit Service 20376f
	"GI7EB~01",
Packit Service 20376f
	"GI7EB~1",
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
void test_path_dotgit__dotgit_modules(void)
Packit Service 20376f
{
Packit Service 20376f
	size_t i;
Packit Service 20376f
	cl_assert_equal_i(1, git_path_is_dotgit_modules(".gitmodules", strlen(".gitmodules")));
Packit Service 20376f
	cl_assert_equal_i(1, git_path_is_dotgit_modules(".git\xe2\x80\x8cmodules", strlen(".git\xe2\x80\x8cmodules")));
Packit Service 20376f
Packit Service 20376f
	for (i = 0; i < ARRAY_SIZE(gitmodules_altnames); i++) {
Packit Service 20376f
		const char *name = gitmodules_altnames[i];
Packit Service 20376f
		if (!git_path_is_dotgit_modules(name, strlen(name)))
Packit Service 20376f
			cl_fail(name);
Packit Service 20376f
	}
Packit Service 20376f
Packit Service 20376f
	for (i = 0; i < ARRAY_SIZE(gitmodules_not_altnames); i++) {
Packit Service 20376f
		const char *name = gitmodules_not_altnames[i];
Packit Service 20376f
		if (git_path_is_dotgit_modules(name, strlen(name)))
Packit Service 20376f
			cl_fail(name);
Packit Service 20376f
	}
Packit Service 20376f
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
void test_path_dotgit__dotgit_modules_symlink(void)
Packit Service 20376f
{
Packit Service 20376f
	cl_assert_equal_b(true, git_path_isvalid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
Packit Service 20376f
	cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
Packit Service 20376f
	cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
Packit Service 20376f
}