0e8ea7e2b8f24edea491cdf865c77158725f89fa
1#!/bin/sh
2#
3# Copyright (c) 2007 Junio C Hamano
4#
5
6test_description='git-apply --whitespace=strip and configuration file.
7
8'
9
10. ./test-lib.sh
11
12test_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'
19
20test_expect_success 'apply --whitespace=strip' '
21
22 cp saved file1 &&
23 git update-index --refresh &&
24
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'
34
35test_expect_success 'apply --whitespace=strip from config' '
36
37 cp saved file1 &&
38 git update-index --refresh &&
39
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'
50
51mkdir sub
52D=`pwd`
53
54test_expect_success 'apply --whitespace=strip in subdir' '
55
56 cd "$D" &&
57 git config --unset-all apply.whitespace
58 cp saved file1 &&
59 git update-index --refresh &&
60
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'
71
72test_expect_success 'apply --whitespace=strip from config in subdir' '
73
74 cd "$D" &&
75 git config apply.whitespace strip &&
76 cp saved file1 &&
77 git update-index --refresh &&
78
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'
89
90test_done