git-apply: require -p<n> when working in a subdirectory.
[git/jnareb-git.git] / t / t4119-apply-config.sh
blob816b5b8fb2388e59d99532f49a5c46f81dfc8125
1 #!/bin/sh
3 # Copyright (c) 2007 Junio C Hamano
6 test_description='git-apply --whitespace=strip and configuration file.
10 . ./test-lib.sh
12 test_expect_success setup '
13 mkdir sub &&
14 echo A >sub/file1 &&
15 cp sub/file1 saved &&
16 git add sub/file1 &&
17 echo "B " >sub/file1 &&
18 git diff >patch.file
21 test_expect_success 'apply --whitespace=strip' '
23 rm -f sub/file1 &&
24 cp saved sub/file1 &&
25 git update-index --refresh &&
27 git apply --whitespace=strip patch.file &&
28 if grep " " sub/file1
29 then
30 echo "Eh?"
31 false
32 else
33 echo Happy
37 test_expect_success 'apply --whitespace=strip from config' '
39 rm -f sub/file1 &&
40 cp saved sub/file1 &&
41 git update-index --refresh &&
43 git config apply.whitespace strip &&
44 git apply patch.file &&
45 if grep " " sub/file1
46 then
47 echo "Eh?"
48 false
49 else
50 echo Happy
54 D=`pwd`
56 test_expect_success 'apply --whitespace=strip in subdir' '
58 cd "$D" &&
59 git config --unset-all apply.whitespace
60 rm -f sub/file1 &&
61 cp saved sub/file1 &&
62 git update-index --refresh &&
64 cd sub &&
65 git apply --whitespace=strip -p2 ../patch.file &&
66 if grep " " file1
67 then
68 echo "Eh?"
69 false
70 else
71 echo Happy
75 test_expect_success 'apply --whitespace=strip from config in subdir' '
77 cd "$D" &&
78 git config apply.whitespace strip &&
79 rm -f sub/file1 &&
80 cp saved sub/file1 &&
81 git update-index --refresh &&
83 cd sub &&
84 git apply -p2 ../patch.file &&
85 if grep " " file1
86 then
87 echo "Eh?"
88 false
89 else
90 echo Happy
94 test_done