Code

git-apply: require -p<n> when working in a subdirectory.
[git.git] / t / t4119-apply-config.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Junio C Hamano
4 #
6 test_description='git-apply --whitespace=strip and configuration file.
8 '
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
19 '
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
34         fi
35 '
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
51         fi
52 '
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
72         fi
73 '
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
91         fi
92 '
94 test_done