3 # Copyright (c) 2007 Junio C Hamano
6 test_description='git apply --whitespace=strip and configuration file.
12 test_expect_success setup '
17 echo "B " >sub/file1 &&
21 # Also handcraft GNU diff output; note this has trailing whitespace.
22 cat >gpatch.file <<\EOF &&
23 --- file1 2007-02-21 01:04:24.000000000 -0800
24 +++ file1+ 2007-02-21 01:07:44.000000000 -0800
30 sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file &&
32 /^--- /s|file1|a/sub/&|
33 /^+++ /s|file1|b/sub/&|
34 ' gpatch.file >gpatch-ab-sub.file &&
50 test_expect_success 'apply --whitespace=strip' '
54 git update-index --refresh &&
56 git apply --whitespace=strip patch.file &&
57 check_result sub/file1
60 test_expect_success 'apply --whitespace=strip from config' '
64 git update-index --refresh &&
66 git config apply.whitespace strip &&
67 git apply patch.file &&
68 check_result sub/file1
73 test_expect_success 'apply --whitespace=strip in subdir' '
76 git config --unset-all apply.whitespace
79 git update-index --refresh &&
82 git apply --whitespace=strip ../patch.file &&
86 test_expect_success 'apply --whitespace=strip from config in subdir' '
89 git config apply.whitespace strip &&
92 git update-index --refresh &&
95 git apply ../patch.file &&
99 test_expect_success 'same in subdir but with traditional patch input' '
102 git config apply.whitespace strip &&
104 cp saved sub/file1 &&
105 git update-index --refresh &&
108 git apply ../gpatch.file &&
112 test_expect_success 'same but with traditional patch input of depth 1' '
115 git config apply.whitespace strip &&
117 cp saved sub/file1 &&
118 git update-index --refresh &&
121 git apply ../gpatch-sub.file &&
125 test_expect_success 'same but with traditional patch input of depth 2' '
128 git config apply.whitespace strip &&
130 cp saved sub/file1 &&
131 git update-index --refresh &&
134 git apply ../gpatch-ab-sub.file &&
138 test_expect_success 'same but with traditional patch input of depth 1' '
141 git config apply.whitespace strip &&
143 cp saved sub/file1 &&
144 git update-index --refresh &&
146 git apply -p0 gpatch-sub.file &&
147 check_result sub/file1
150 test_expect_success 'same but with traditional patch input of depth 2' '
153 git config apply.whitespace strip &&
155 cp saved sub/file1 &&
156 git update-index --refresh &&
158 git apply gpatch-ab-sub.file &&
159 check_result sub/file1