Code

Teach 'git apply' to look at $GIT_DIR/config
[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         echo A >file1 &&
14         cp file1 saved &&
15         git add file1 &&
16         echo "B " >file1 &&
17         git diff >patch.file
18 '
20 test_expect_success 'apply --whitespace=strip' '
22         cp saved file1 &&
23         git update-index --refresh &&
25         git apply --whitespace=strip patch.file &&
26         if grep " " file1
27         then
28                 echo "Eh?"
29                 false
30         else
31                 echo Happy
32         fi
33 '
35 test_expect_success 'apply --whitespace=strip from config' '
37         cp saved file1 &&
38         git update-index --refresh &&
40         git config apply.whitespace strip &&
41         git apply patch.file &&
42         if grep " " file1
43         then
44                 echo "Eh?"
45                 false
46         else
47                 echo Happy
48         fi
49 '
51 mkdir sub
52 D=`pwd`
54 test_expect_success 'apply --whitespace=strip in subdir' '
56         cd "$D" &&
57         git config --unset-all apply.whitespace
58         cp saved file1 &&
59         git update-index --refresh &&
61         cd sub &&
62         git apply --whitespace=strip ../patch.file &&
63         if grep " " ../file1
64         then
65                 echo "Eh?"
66                 false
67         else
68                 echo Happy
69         fi
70 '
72 test_expect_success 'apply --whitespace=strip from config in subdir' '
74         cd "$D" &&
75         git config apply.whitespace strip &&
76         cp saved file1 &&
77         git update-index --refresh &&
79         cd sub &&
80         git apply ../patch.file &&
81         if grep " " file1
82         then
83                 echo "Eh?"
84                 false
85         else
86                 echo Happy
87         fi
88 '
90 test_done