summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-01-14 13:15:34 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-01-16 18:50:00 -0500
commitdd3c53f15610decf14c76cfef448cc17eab4e7af (patch)
treee49f80cbf26cf12f12d0cec67d27d13b049fb0d9
parent629a5791bb7b4da1416b92664baeab75c69bc91a (diff)
downloadlibgit2-dd3c53f15610decf14c76cfef448cc17eab4e7af.tar.gz
checkout tests: nasty symlinks
Symbolic links that abuse case insensitivity to write into .git.
-rw-r--r--tests/checkout/nasty.c40
-rw-r--r--tests/resources/nasty/.gitted/objects/14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725bin0 -> 48 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9bin0 -> 19 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea2
-rw-r--r--tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a2
-rw-r--r--tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279bin0 -> 83 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954dfbin0 -> 138 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b190314
-rw-r--r--tests/resources/nasty/.gitted/objects/a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2bin0 -> 166 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819bin0 -> 86 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/ac/84d85a425b2a21fd0ffccacac6c48823fc98c8bin0 -> 48 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/bc/e2dabe5766838216d95f199d95aa4fd479a084bin0 -> 83 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd72
-rw-r--r--tests/resources/nasty/.gitted/objects/e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6bin0 -> 51 bytes
-rw-r--r--tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55bin0 -> 49 bytes
-rw-r--r--tests/resources/nasty/.gitted/refs/heads/symlink11
-rw-r--r--tests/resources/nasty/.gitted/refs/heads/symlink21
-rw-r--r--tests/resources/nasty/.gitted/refs/heads/symlink31
18 files changed, 50 insertions, 3 deletions
diff --git a/tests/checkout/nasty.c b/tests/checkout/nasty.c
index c07d9382a..bc25a3b52 100644
--- a/tests/checkout/nasty.c
+++ b/tests/checkout/nasty.c
@@ -23,7 +23,29 @@ void test_checkout_nasty__cleanup(void)
cl_git_sandbox_cleanup();
}
-void test_checkout_fails(const char *refname, const char *filename)
+static void test_checkout_passes(const char *refname, const char *filename)
+{
+ git_oid commit_id;
+ git_commit *commit;
+ git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_buf path = GIT_BUF_INIT;
+
+ cl_git_pass(git_buf_joinpath(&path, repo_name, filename));
+
+ cl_git_pass(git_reference_name_to_id(&commit_id, repo, refname));
+ cl_git_pass(git_commit_lookup(&commit, repo, &commit_id));
+
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE |
+ GIT_CHECKOUT_DONT_UPDATE_INDEX;
+
+ cl_git_pass(git_checkout_tree(repo, (const git_object *)commit, &opts));
+ cl_assert(!git_path_exists(path.ptr));
+
+ git_commit_free(commit);
+ git_buf_free(&path);
+}
+
+static void test_checkout_fails(const char *refname, const char *filename)
{
git_oid commit_id;
git_commit *commit;
@@ -323,3 +345,19 @@ void test_checkout_nasty__honors_core_protectntfs(void)
test_checkout_fails("refs/heads/dot_git_dot", ".git/foobar");
test_checkout_fails("refs/heads/git_tilde1", ".git/foobar");
}
+
+void test_checkout_nasty__symlink1(void)
+{
+ test_checkout_passes("refs/heads/symlink1", ".git/foobar");
+}
+
+void test_checkout_nasty__symlink2(void)
+{
+ test_checkout_passes("refs/heads/symlink2", ".git/foobar");
+}
+
+void test_checkout_nasty__symlink3(void)
+{
+ test_checkout_passes("refs/heads/symlink3", ".git/foobar");
+}
+
diff --git a/tests/resources/nasty/.gitted/objects/14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725 b/tests/resources/nasty/.gitted/objects/14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725
new file mode 100644
index 000000000..371951aac
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9 b/tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9
new file mode 100644
index 000000000..f1619a22e
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea b/tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea
deleted file mode 100644
index 20ede1bab..000000000
--- a/tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea
+++ /dev/null
@@ -1,2 +0,0 @@
-xa
-!)Z|t"O' >1׈}ݠ5 ̄Zʭî7ffV)JC9Y%URN~fcgsmp/"\s-k}/M q쥖R :;9#.wmz@ \ No newline at end of file
diff --git a/tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a b/tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a
new file mode 100644
index 000000000..d362f1dce
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a
@@ -0,0 +1,2 @@
+xK
+1D]}Dx/O NH"2wo=5e@}L<%AD̄VI:%IrIDPs̵-|KpkvIW_;Ś/@-WGTl?gX}lзDX`oԙD \ No newline at end of file
diff --git a/tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279 b/tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279
new file mode 100644
index 000000000..e6640e6c7
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df b/tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df
new file mode 100644
index 000000000..da9d5c467
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031 b/tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031
new file mode 100644
index 000000000..7cb310622
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031
@@ -0,0 +1,4 @@
+xO[ S4 R
+Icz
+۴t bK7k^L&pJS%qS2T=51vo45tzuQFpO#\FNw^HvVQTFߩy
+0Ouy$>F \ No newline at end of file
diff --git a/tests/resources/nasty/.gitted/objects/a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2 b/tests/resources/nasty/.gitted/objects/a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2
new file mode 100644
index 000000000..c1de43b2a
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819 b/tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819
new file mode 100644
index 000000000..78c2fe4f8
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/ac/84d85a425b2a21fd0ffccacac6c48823fc98c8 b/tests/resources/nasty/.gitted/objects/ac/84d85a425b2a21fd0ffccacac6c48823fc98c8
new file mode 100644
index 000000000..b08e24740
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/ac/84d85a425b2a21fd0ffccacac6c48823fc98c8
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/bc/e2dabe5766838216d95f199d95aa4fd479a084 b/tests/resources/nasty/.gitted/objects/bc/e2dabe5766838216d95f199d95aa4fd479a084
new file mode 100644
index 000000000..b1eab1005
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/bc/e2dabe5766838216d95f199d95aa4fd479a084
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7 b/tests/resources/nasty/.gitted/objects/cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7
new file mode 100644
index 000000000..f65e8ff6e
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7
@@ -0,0 +1,2 @@
+x]
+0})Jm `ӕQooo70x9@%7e%kh0QAGi5F^ +î/0Ruos;yEöBֈ+;9-uoG \ No newline at end of file
diff --git a/tests/resources/nasty/.gitted/objects/e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6 b/tests/resources/nasty/.gitted/objects/e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6
new file mode 100644
index 000000000..3d12f3a80
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6
Binary files differ
diff --git a/tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55 b/tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55
new file mode 100644
index 000000000..8311ad31b
--- /dev/null
+++ b/tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55
Binary files differ
diff --git a/tests/resources/nasty/.gitted/refs/heads/symlink1 b/tests/resources/nasty/.gitted/refs/heads/symlink1
new file mode 100644
index 000000000..efa2e88b6
--- /dev/null
+++ b/tests/resources/nasty/.gitted/refs/heads/symlink1
@@ -0,0 +1 @@
+4d83272d0d372e1232ddc4ff3260d76fdfa2015a
diff --git a/tests/resources/nasty/.gitted/refs/heads/symlink2 b/tests/resources/nasty/.gitted/refs/heads/symlink2
new file mode 100644
index 000000000..e4f3d6067
--- /dev/null
+++ b/tests/resources/nasty/.gitted/refs/heads/symlink2
@@ -0,0 +1 @@
+9d5898503adc01d763e279ac8fcefbe865b19031
diff --git a/tests/resources/nasty/.gitted/refs/heads/symlink3 b/tests/resources/nasty/.gitted/refs/heads/symlink3
new file mode 100644
index 000000000..2b33e4ff7
--- /dev/null
+++ b/tests/resources/nasty/.gitted/refs/heads/symlink3
@@ -0,0 +1 @@
+cf6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7