3 # Copyright (c) 2007 Junio C Hamano
6 test_description
='git apply --whitespace=strip and configuration file.
11 TEST_PASSES_SANITIZE_LEAK
=true
14 test_expect_success setup
'
19 echo "B " >sub/file1 &&
23 # Also handcraft GNU diff output; note this has trailing whitespace.
24 tr '_' ' ' >gpatch.
file <<\EOF
&&
25 --- file1
2007-02-21 01:04:24.000000000 -0800
26 +++ file1
+ 2007-02-21 01:07:44.000000000 -0800
32 sed -e 's|file1|sub/&|' gpatch.
file >gpatch-sub.
file &&
34 /^--- /s|file1|a/sub/&|
35 /^+++ /s|file1|b/sub/&|
36 ' gpatch.
file >gpatch-ab-sub.
file &&
52 test_expect_success
'apply --whitespace=strip' '
56 git update-index --refresh &&
58 git apply --whitespace=strip patch.file &&
59 check_result sub/file1
62 test_expect_success
'apply --whitespace=strip from config' '
66 git update-index --refresh &&
68 git config apply.whitespace strip &&
69 git apply patch.file &&
70 check_result sub/file1
75 test_expect_success
'apply --whitespace=strip in subdir' '
78 git config --unset-all apply.whitespace &&
81 git update-index --refresh &&
84 git apply --whitespace=strip ../patch.file &&
88 test_expect_success
'apply --whitespace=strip from config in subdir' '
91 git config apply.whitespace strip &&
94 git update-index --refresh &&
97 git apply ../patch.file &&
101 test_expect_success
'same in subdir but with traditional patch input' '
104 git config apply.whitespace strip &&
106 cp saved sub/file1 &&
107 git update-index --refresh &&
110 git apply ../gpatch.file &&
114 test_expect_success
'same but with traditional patch input of depth 1' '
117 git config apply.whitespace strip &&
119 cp saved sub/file1 &&
120 git update-index --refresh &&
123 git apply ../gpatch-sub.file &&
127 test_expect_success
'same but with traditional patch input of depth 2' '
130 git config apply.whitespace strip &&
132 cp saved sub/file1 &&
133 git update-index --refresh &&
136 git apply ../gpatch-ab-sub.file &&
140 test_expect_success
'same but with traditional patch input of depth 1' '
143 git config apply.whitespace strip &&
145 cp saved sub/file1 &&
146 git update-index --refresh &&
148 git apply -p0 gpatch-sub.file &&
149 check_result sub/file1
152 test_expect_success
'same but with traditional patch input of depth 2' '
155 git config apply.whitespace strip &&
157 cp saved sub/file1 &&
158 git update-index --refresh &&
160 git apply gpatch-ab-sub.file &&
161 check_result sub/file1
164 test_expect_success
'in subdir with traditional patch input' '
166 git config apply.whitespace strip &&
167 cat >.gitattributes <<-EOF &&
168 /* whitespace=blank-at-eol
169 sub/* whitespace=-blank-at-eol
172 cp saved sub/file1 &&
173 git update-index --refresh &&
176 git apply ../gpatch.file &&
178 test_cmp expect file1