From 232bc89598947823e57431df63a5d6d41ad218c3 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 14 Jan 2015 13:15:34 -0500 Subject: [PATCH] checkout tests: nasty symlinks Symbolic links that abuse case insensitivity to write into .git. --- tests/checkout/nasty.c | 40 +++++++++++++++++- .../14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725 | Bin 0 -> 48 bytes .../19/1381ee74dec49c89f99a62d055cb1058ba0de9 | Bin 0 -> 19 bytes .../1b/31d55e0c53efbea6c670ece9057b76b5822eea | Bin 132 -> 0 bytes .../4d/83272d0d372e1232ddc4ff3260d76fdfa2015a | Bin 0 -> 140 bytes .../7b/b1dd08b2c7d73084934954e4196e67004b0279 | Bin 0 -> 83 bytes .../91/cd2c95af92883550b45fcc838013ae7e2954df | Bin 0 -> 138 bytes .../9d/5898503adc01d763e279ac8fcefbe865b19031 | Bin 0 -> 143 bytes .../a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2 | Bin 0 -> 166 bytes .../a7/8dde970cffbb71d67bef2a74aa72c6621d9819 | Bin 0 -> 86 bytes .../ac/84d85a425b2a21fd0ffccacac6c48823fc98c8 | Bin 0 -> 48 bytes .../bc/e2dabe5766838216d95f199d95aa4fd479a084 | Bin 0 -> 83 bytes .../cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7 | Bin 0 -> 146 bytes .../e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6 | Bin 0 -> 51 bytes .../e8/68b1d6833710021785581a9e11dba8468f3a55 | Bin 0 -> 49 bytes .../nasty/.gitted/refs/heads/symlink1 | Bin 0 -> 41 bytes .../nasty/.gitted/refs/heads/symlink2 | Bin 0 -> 41 bytes .../nasty/.gitted/refs/heads/symlink3 | Bin 0 -> 41 bytes 18 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/resources/nasty/.gitted/objects/14/e70ab559b4c6a8a6fc9b6f538bd1f3934be725 create mode 100644 tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9 delete mode 100644 tests/resources/nasty/.gitted/objects/1b/31d55e0c53efbea6c670ece9057b76b5822eea create mode 100644 tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a create mode 100644 tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279 create mode 100644 tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df create mode 100644 tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031 create mode 100644 tests/resources/nasty/.gitted/objects/a0/d89aa95628fcd6b64fd5b23dd56b906b06bfe2 create mode 100644 tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819 create mode 100644 tests/resources/nasty/.gitted/objects/ac/84d85a425b2a21fd0ffccacac6c48823fc98c8 create mode 100644 tests/resources/nasty/.gitted/objects/bc/e2dabe5766838216d95f199d95aa4fd479a084 create mode 100644 tests/resources/nasty/.gitted/objects/cf/6fcf8cdf7e8d4cda3b11b0ba02d0d5125fbbd7 create mode 100644 tests/resources/nasty/.gitted/objects/e5/1c3fa44fe981ec290c8f47fea736f3ff2af2a6 create mode 100644 tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55 create mode 100644 tests/resources/nasty/.gitted/refs/heads/symlink1 create mode 100644 tests/resources/nasty/.gitted/refs/heads/symlink2 create mode 100644 tests/resources/nasty/.gitted/refs/heads/symlink3 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 0000000000000000000000000000000000000000..371951aac13115d19bc037e06b21a6cd5c32697e GIT binary patch literal 48 zcmV-00MGw;0ZYosPf{>8VhG8|ELJEl$}CAORw&6=NK`1U%uUMA$xK$r$;`{v;{pH^ GlnsaBNfhb; literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9 b/tests/resources/nasty/.gitted/objects/19/1381ee74dec49c89f99a62d055cb1058ba0de9 new file mode 100644 index 0000000000000000000000000000000000000000..f1619a22e046155d12776bdd42fd78db87e0d188 GIT binary patch literal 19 acmb%`G2xeA<6e&uJL!>!bB~?-woKAjbW36Wv{@HVFaE>qEB3yGVYkk0x2mQE( mzr`<2p_UUMp>d?h5$vUwQVcrIJO4Q&E_c7?ZF&Q^89=!Oy*lgw diff --git a/tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a b/tests/resources/nasty/.gitted/objects/4d/83272d0d372e1232ddc4ff3260d76fdfa2015a new file mode 100644 index 0000000000000000000000000000000000000000..d362f1dce18fb5930fd206f20dfb7d903c2934b0 GIT binary patch literal 140 zcmV;70CWF%0i}&g3IZ_@L|x|;eF3GD$rnW2cmpqxPs0pO5=bI4w|5k8;I8UDsERe` zWq?3^7>x)_2s|aUK}3_xgjTvqIweVRr%4+`8BiF<{Bz8;!7aUfOK_iS?zO;~cKS(I u`ifsW#hNd`r9j6mR|rQ`h-|0(`Jg{%Sn+*q(6=1wx5bwAqx literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279 b/tests/resources/nasty/.gitted/objects/7b/b1dd08b2c7d73084934954e4196e67004b0279 new file mode 100644 index 0000000000000000000000000000000000000000..e6640e6c71232111b59d628603eedbe0f67e673e GIT binary patch literal 83 zcmV-Z0IdIb0V^p=O;s?nWH2-`00IRkM;9MYKW_#};l_6*_m0fz{5dP>Lg;CMh+Vud pO~5LW5>s+A^RgM9%GfXQf7$p(lc(SP-*U6h|Fu3X0{|q>A6HtsB{2X1 literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df b/tests/resources/nasty/.gitted/objects/91/cd2c95af92883550b45fcc838013ae7e2954df new file mode 100644 index 0000000000000000000000000000000000000000..da9d5c46736658c645d71008944d1cc678f442b6 GIT binary patch literal 138 zcmV;50CoR(0V^p=O;s>7HefI`G5`VvCr1|_Pd{%4N#VwKCHIcZ>HIk>=|bpffrwqa zFHOKI{QX=R*0kJ+a*Ebc{LBC6)Tv`fI+Xv+I02DON=(Vg%*$qYDr3LI|7GJFO`d-D sf6L82|JVAo3~EJwUMfSJ!-4jKh@&hDmPSv769UiMTn?NK0FQ__;@WLN-2eap literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031 b/tests/resources/nasty/.gitted/objects/9d/5898503adc01d763e279ac8fcefbe865b19031 new file mode 100644 index 0000000000000000000000000000000000000000..7cb310622251f4656fed1837d60bf1b592351d87 GIT binary patch literal 143 zcmV;A0C4|!0i{n{4#FT1^qW)c1vCp%3Q1%9@dSDS3fr`?bPZzE+e?i%@M~VlOeSzj zQvoG$Q!)|sfmHN8HLWprZ7Gh{F{G5`VvCr1|_Pd{%4N#VwKCHIcZ>HIk>=|bpffrwqa zFHOKI{QX=R*0kJ+a*Ebc{LBC6)Tv`fI+Xv+I02DOEKW&dc#*O3TC=$TlXz={)I7o4 zE8P06LLt&gi77dmdD#q4W$c&uzifP?$);wX!P UrO{L2guwGQmjh=50GrT4-z8d8x&QzG literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819 b/tests/resources/nasty/.gitted/objects/a7/8dde970cffbb71d67bef2a74aa72c6621d9819 new file mode 100644 index 0000000000000000000000000000000000000000..78c2fe4f82fb28305c7337015557bd8c868b8b10 GIT binary patch literal 86 zcmV-c0IC0Y0V^p=O;s>AVlXr^00IRkM;9MYKW_#};l_6*_m0fz{5dP>Lg;CMh+Vud sO~5LW5>p;E^yFmbWivdLv0vi39FP-0bsztxwAg pjlfEh5>s+A^RgKvg&W_M+&eO-^XIIj3!$e4B6jh<1OPW&A6KplB)ZIc#?_~Hrl0{Pj{VAGWvQEzV)Z{XX^H!#C^ z&N&r8B{yXy0&DsZXfV>p=$uhO8%GhXX{|NrwMG?&UJb(D%fu@j!^5rt&J*VwFECQ2 zA9bK_@N+xQc@L^Zg}TGGfvxPM6qVNTLVwnX(9VK6i>Ff%bxNXySpN-Sa!dCs*pa?7z5%l^#H5AMGBd9wF& JRRA&w5pCXI6#oDK literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55 b/tests/resources/nasty/.gitted/objects/e8/68b1d6833710021785581a9e11dba8468f3a55 new file mode 100644 index 0000000000000000000000000000000000000000..8311ad31ba004280931e2433b6b23b35f7bbdf44 GIT binary patch literal 49 zcmV-10M7q-0V^p=O;s>9VlXr?Ff%bxNGwiCW9Yt?(s$8d&AfB`oo8qD@BXXC;Zy|x H7Mu^i$ literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/refs/heads/symlink2 b/tests/resources/nasty/.gitted/refs/heads/symlink2 new file mode 100644 index 0000000000000000000000000000000000000000..e4f3d60678a6066dc6c7d233eb9b74c5970a5d1b GIT binary patch literal 41 vcmV~$Nf7`r2n4Wy)j%1_B8StzgeKk!hmu4Waodx*=26(1&B4=TC*kt}>gfv% literal 0 HcmV?d00001 diff --git a/tests/resources/nasty/.gitted/refs/heads/symlink3 b/tests/resources/nasty/.gitted/refs/heads/symlink3 new file mode 100644 index 0000000000000000000000000000000000000000..2b33e4ff78dab0c769d51bcb5c11f48576494ac6 GIT binary patch literal 41 ucmV~$$pHW$2m`Rc(|{MOL#f?=1e4ZPE1Qa!+|62WhoNlJczhlKjPU^!EevV^ literal 0 HcmV?d00001