summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-12-16 18:53:55 -0600
committerEdward Thomson <ethomson@edwardthomson.com>2014-12-17 12:52:07 -0500
commitec74b40ceef3dc3892c7d84bb4f5d99bab504ba4 (patch)
treea33dbb62e0f08e14730557695bd911037079c0af /tests
parent8e35527de25ac156f3600e2ce49b0c3483c258c4 (diff)
downloadlibgit2-ec74b40ceef3dc3892c7d84bb4f5d99bab504ba4.tar.gz
Introduce core.protectHFS and core.protectNTFS
Validate HFS ignored char ".git" paths when `core.protectHFS` is specified. Validate NTFS invalid ".git" paths when `core.protectNTFS` is specified.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkout/nasty.c32
-rw-r--r--tests/path/core.c22
2 files changed, 51 insertions, 3 deletions
diff --git a/tests/checkout/nasty.c b/tests/checkout/nasty.c
index a667dcd8f..c07d9382a 100644
--- a/tests/checkout/nasty.c
+++ b/tests/checkout/nasty.c
@@ -291,3 +291,35 @@ void test_checkout_nasty__dot_git_hfs_ignorable(void)
test_checkout_fails("refs/heads/dotgit_hfs_ignorable_16", ".git/foobar");
#endif
}
+
+void test_checkout_nasty__honors_core_protecthfs(void)
+{
+ cl_repo_set_bool(repo, "core.protectHFS", true);
+
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_1", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_2", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_3", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_4", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_5", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_6", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_7", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_8", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_9", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_10", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_11", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_12", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_13", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_14", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_15", ".git/foobar");
+ test_checkout_fails("refs/heads/dotgit_hfs_ignorable_16", ".git/foobar");
+}
+
+void test_checkout_nasty__honors_core_protectntfs(void)
+{
+ cl_repo_set_bool(repo, "core.protectNTFS", true);
+
+ test_checkout_fails("refs/heads/dotgit_backslash_path", ".git/foobar");
+ test_checkout_fails("refs/heads/dotcapitalgit_backslash_path", ".GIT/foobar");
+ test_checkout_fails("refs/heads/dot_git_dot", ".git/foobar");
+ test_checkout_fails("refs/heads/git_tilde1", ".git/foobar");
+}
diff --git a/tests/path/core.c b/tests/path/core.c
index 528108bea..85fee820a 100644
--- a/tests/path/core.c
+++ b/tests/path/core.c
@@ -172,11 +172,27 @@ void test_path_core__isvalid_trailing_colon(void)
cl_assert_equal_b(false, git_path_isvalid(NULL, "foo:/bar", GIT_PATH_REJECT_TRAILING_COLON));
}
-void test_path_core__isvalid_dos_git_shortname(void)
+void test_path_core__isvalid_dotgit_ntfs(void)
{
- cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, ".git", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, ".git ", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, ".git.", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, ".git.. .", 0));
- cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1", GIT_PATH_REJECT_DOS_GIT_SHORTNAME));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1 ", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1.", 0));
+ cl_assert_equal_b(true, git_path_isvalid(NULL, "git~1.. .", 0));
+
+ cl_assert_equal_b(false, git_path_isvalid(NULL, ".git", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, ".git ", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, ".git.", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, ".git.. .", GIT_PATH_REJECT_DOT_GIT_NTFS));
+
+ cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1 ", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1.", GIT_PATH_REJECT_DOT_GIT_NTFS));
+ cl_assert_equal_b(false, git_path_isvalid(NULL, "git~1.. .", GIT_PATH_REJECT_DOT_GIT_NTFS));
}
void test_path_core__isvalid_dos_paths(void)