builtin/blame.c: remove '--indent-heuristic' from usage string
[git/debian.git] / t / t4122-apply-symlink-inside.sh
blob4acb3f336ed3fac10c7ddf68868c3ff56db94978
1 #!/bin/sh
3 test_description='apply to deeper directory without getting fooled with symlink'
4 . ./test-lib.sh
6 test_expect_success setup '
8 mkdir -p arch/i386/boot arch/x86_64 &&
9 test_write_lines 1 2 3 4 5 >arch/i386/boot/Makefile &&
10 test_ln_s_add ../i386/boot arch/x86_64/boot &&
11 git add . &&
12 test_tick &&
13 git commit -m initial &&
14 git branch test &&
16 rm arch/x86_64/boot &&
17 mkdir arch/x86_64/boot &&
18 test_write_lines 2 3 4 5 6 >arch/x86_64/boot/Makefile &&
19 git add . &&
20 test_tick &&
21 git commit -a -m second &&
23 git format-patch --binary -1 --stdout >test.patch
27 test_expect_success apply '
29 git checkout test &&
30 git diff --exit-code test &&
31 git diff --exit-code --cached test &&
32 git apply --index test.patch
36 test_expect_success 'check result' '
38 git diff --exit-code master &&
39 git diff --exit-code --cached master &&
40 test_tick &&
41 git commit -m replay &&
42 T1=$(git rev-parse "master^{tree}") &&
43 T2=$(git rev-parse "HEAD^{tree}") &&
44 test "z$T1" = "z$T2"
48 test_expect_success SYMLINKS 'do not read from beyond symbolic link' '
49 git reset --hard &&
50 mkdir -p arch/x86_64/dir &&
51 >arch/x86_64/dir/file &&
52 git add arch/x86_64/dir/file &&
53 echo line >arch/x86_64/dir/file &&
54 git diff >patch &&
55 git reset --hard &&
57 mkdir arch/i386/dir &&
58 >arch/i386/dir/file &&
59 ln -s ../i386/dir arch/x86_64/dir &&
61 test_must_fail git apply patch &&
62 test_must_fail git apply --cached patch &&
63 test_must_fail git apply --index patch
67 test_expect_success SYMLINKS 'do not follow symbolic link (setup)' '
69 rm -rf arch/i386/dir arch/x86_64/dir &&
70 git reset --hard &&
71 ln -s ../i386/dir arch/x86_64/dir &&
72 git add arch/x86_64/dir &&
73 git diff HEAD >add_symlink.patch &&
74 git reset --hard &&
76 mkdir arch/x86_64/dir &&
77 >arch/x86_64/dir/file &&
78 git add arch/x86_64/dir/file &&
79 git diff HEAD >add_file.patch &&
80 git diff -R HEAD >del_file.patch &&
81 git reset --hard &&
82 rm -fr arch/x86_64/dir &&
84 cat add_symlink.patch add_file.patch >patch &&
85 cat add_symlink.patch del_file.patch >tricky_del &&
87 mkdir arch/i386/dir
90 test_expect_success SYMLINKS 'do not follow symbolic link (same input)' '
92 # same input creates a confusing symbolic link
93 test_must_fail git apply patch 2>error-wt &&
94 test_i18ngrep "beyond a symbolic link" error-wt &&
95 test_path_is_missing arch/x86_64/dir &&
96 test_path_is_missing arch/i386/dir/file &&
98 test_must_fail git apply --index patch 2>error-ix &&
99 test_i18ngrep "beyond a symbolic link" error-ix &&
100 test_path_is_missing arch/x86_64/dir &&
101 test_path_is_missing arch/i386/dir/file &&
102 test_must_fail git ls-files --error-unmatch arch/x86_64/dir &&
103 test_must_fail git ls-files --error-unmatch arch/i386/dir &&
105 test_must_fail git apply --cached patch 2>error-ct &&
106 test_i18ngrep "beyond a symbolic link" error-ct &&
107 test_must_fail git ls-files --error-unmatch arch/x86_64/dir &&
108 test_must_fail git ls-files --error-unmatch arch/i386/dir &&
110 >arch/i386/dir/file &&
111 git add arch/i386/dir/file &&
113 test_must_fail git apply tricky_del &&
114 test_path_is_file arch/i386/dir/file &&
116 test_must_fail git apply --index tricky_del &&
117 test_path_is_file arch/i386/dir/file &&
118 test_must_fail git ls-files --error-unmatch arch/x86_64/dir &&
119 git ls-files --error-unmatch arch/i386/dir &&
121 test_must_fail git apply --cached tricky_del &&
122 test_must_fail git ls-files --error-unmatch arch/x86_64/dir &&
123 git ls-files --error-unmatch arch/i386/dir
126 test_expect_success SYMLINKS 'do not follow symbolic link (existing)' '
128 # existing symbolic link
129 git reset --hard &&
130 ln -s ../i386/dir arch/x86_64/dir &&
131 git add arch/x86_64/dir &&
133 test_must_fail git apply add_file.patch 2>error-wt-add &&
134 test_i18ngrep "beyond a symbolic link" error-wt-add &&
135 test_path_is_missing arch/i386/dir/file &&
137 mkdir arch/i386/dir &&
138 >arch/i386/dir/file &&
139 test_must_fail git apply del_file.patch 2>error-wt-del &&
140 test_i18ngrep "beyond a symbolic link" error-wt-del &&
141 test_path_is_file arch/i386/dir/file &&
142 rm arch/i386/dir/file &&
144 test_must_fail git apply --index add_file.patch 2>error-ix-add &&
145 test_i18ngrep "beyond a symbolic link" error-ix-add &&
146 test_path_is_missing arch/i386/dir/file &&
147 test_must_fail git ls-files --error-unmatch arch/i386/dir &&
149 test_must_fail git apply --cached add_file.patch 2>error-ct-file &&
150 test_i18ngrep "beyond a symbolic link" error-ct-file &&
151 test_must_fail git ls-files --error-unmatch arch/i386/dir
154 test_done