3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='git apply symlinks and partial files
10 TEST_PASSES_SANITIZE_LEAK
=true
13 test_expect_success setup
'
15 test_ln_s_add path1/path2/path3/path4/path5 link1 &&
16 git commit -m initial &&
22 test_ln_s_add htap6 link1 &&
23 git commit -m second &&
25 git diff-tree -p HEAD^ HEAD >patch &&
26 git apply --stat --summary patch
30 test_expect_success SYMLINKS
'apply symlink patch' '
34 git diff-files -p >patched &&
35 test_cmp patch patched
39 test_expect_success
'apply --index symlink patch' '
41 git checkout -f side &&
42 git apply --index patch &&
43 git diff-index --cached -p HEAD >patched &&
44 test_cmp patch patched
48 test_expect_success
'symlink setup' '
51 git commit -m "add symlink"
54 test_expect_success SYMLINKS
'symlink escape when creating new files' '
55 test_when_finished "git reset --hard && git clean -dfx" &&
58 diff --git a/symlink b/renamed-symlink
61 rename to renamed-symlink
63 diff --git /dev/null b/renamed-symlink/create-me
65 index 0000000..039727e
67 +++ b/renamed-symlink/create-me
72 test_must_fail git apply patch 2>stderr &&
73 cat >expected_stderr <<-EOF &&
74 error: affected file ${SQ}renamed-symlink/create-me${SQ} is beyond a symbolic link
76 test_cmp expected_stderr stderr &&
77 ! test_path_exists .git/create-me
80 test_expect_success SYMLINKS
'symlink escape when modifying file' '
81 test_when_finished "git reset --hard && git clean -dfx" &&
82 touch .git/modify-me &&
85 diff --git a/symlink b/renamed-symlink
88 rename to renamed-symlink
90 diff --git a/renamed-symlink/modify-me b/renamed-symlink/modify-me
91 index 1111111..2222222 100644
92 --- a/renamed-symlink/modify-me
93 +++ b/renamed-symlink/modify-me
98 test_must_fail git apply patch 2>stderr &&
99 cat >expected_stderr <<-EOF &&
100 error: renamed-symlink/modify-me: No such file or directory
102 test_cmp expected_stderr stderr &&
103 test_must_be_empty .git/modify-me
106 test_expect_success SYMLINKS
'symlink escape when deleting file' '
107 test_when_finished "git reset --hard && git clean -dfx && rm .git/delete-me" &&
108 touch .git/delete-me &&
111 diff --git a/symlink b/renamed-symlink
112 similarity index 100%
114 rename to renamed-symlink
116 diff --git a/renamed-symlink/delete-me b/renamed-symlink/delete-me
117 deleted file mode 100644
118 index 1111111..0000000 100644
121 test_must_fail git apply patch 2>stderr &&
122 cat >expected_stderr <<-EOF &&
123 error: renamed-symlink/delete-me: No such file or directory
125 test_cmp expected_stderr stderr &&
126 test_path_is_file .git/delete-me