@matheusbsbs / matheus-bagliano / commits / fe6e0eecb0
Fork 0

t4119: test autocomputing -p<n> for traditional diff input.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 21, 2007 at 16:18 UTC fe6e0eecb03379e6acb742f77b0b5f589a7b7422
1 file changed +43 -74
t/t4119-apply-config.sh
+43 -74
@@ -33,24 +33,28 @@ sed -e '
33 /^+++ /s|file1|b/sub/&|
34 ' gpatch.file >gpatch-ab-sub.file &&
35
36 -test_expect_success 'apply --whitespace=strip' '
37 -
38 - rm -f sub/file1 &&
39 - cp saved sub/file1 &&
40 - git update-index --refresh &&
41 -
42 - git apply --whitespace=strip patch.file &&
43 - if grep " " sub/file1
36 +check_result () {
37 + if grep " " "$1"
38 then
39 echo "Eh?"
40 false
47 - elif grep B sub/file1
41 + elif grep B "$1"
42 then
43 echo Happy
44 else
45 echo "Huh?"
46 false
47 fi
48 +}
49 +
50 +test_expect_success 'apply --whitespace=strip' '
51 +
52 + rm -f sub/file1 &&
53 + cp saved sub/file1 &&
54 + git update-index --refresh &&
55 +
56 + git apply --whitespace=strip patch.file &&
57 + check_result sub/file1
58 '
59
60 test_expect_success 'apply --whitespace=strip from config' '
@@ -61,16 +65,7 @@ test_expect_success 'apply --whitespace=strip from config' '
65
66 git config apply.whitespace strip &&
67 git apply patch.file &&
64 - if grep " " sub/file1
65 - then
66 - echo "Eh?"
67 - false
68 - elif grep B sub/file1
69 - then
70 - echo Happy
71 - else
72 - echo Happy
73 - fi
68 + check_result sub/file1
69 '
70
71 D=`pwd`
@@ -85,17 +80,7 @@ test_expect_success 'apply --whitespace=strip in subdir' '
80
81 cd sub &&
82 git apply --whitespace=strip ../patch.file &&
88 - if grep " " file1
89 - then
90 - echo "Eh?"
91 - false
92 - elif grep B file1
93 - then
94 - echo Happy
95 - else
96 - echo "Huh?"
97 - false
98 - fi
83 + check_result file1
84 '
85
86 test_expect_success 'apply --whitespace=strip from config in subdir' '
@@ -108,17 +93,7 @@ test_expect_success 'apply --whitespace=strip from config in subdir' '
93
94 cd sub &&
95 git apply ../patch.file &&
111 - if grep " " file1
112 - then
113 - echo "Eh?"
114 - false
115 - elif grep B file1
116 - then
117 - echo Happy
118 - else
119 - echo "Huh?"
120 - false
121 - fi
96 + check_result file1
97 '
98
99 test_expect_success 'same in subdir but with traditional patch input' '
@@ -131,17 +106,7 @@ test_expect_success 'same in subdir but with traditional patch input' '
106
107 cd sub &&
108 git apply ../gpatch.file &&
134 - if grep " " file1
135 - then
136 - echo "Eh?"
137 - false
138 - elif grep B file1
139 - then
140 - echo Happy
141 - else
142 - echo "Huh?"
143 - false
144 - fi
109 + check_result file1
110 '
111
112 test_expect_success 'same but with traditional patch input of depth 1' '
@@ -154,17 +119,7 @@ test_expect_success 'same but with traditional patch input of depth 1' '
119
120 cd sub &&
121 git apply ../gpatch-sub.file &&
157 - if grep " " file1
158 - then
159 - echo "Eh?"
160 - false
161 - elif grep B file1
162 - then
163 - echo Happy
164 - else
165 - echo "Huh?"
166 - false
167 - fi
122 + check_result file1
123 '
124
125 test_expect_success 'same but with traditional patch input of depth 2' '
@@ -177,17 +132,31 @@ test_expect_success 'same but with traditional patch input of depth 2' '
132
133 cd sub &&
134 git apply ../gpatch-ab-sub.file &&
180 - if grep " " file1
181 - then
182 - echo "Eh?"
183 - false
184 - elif grep B file1
185 - then
186 - echo Happy
187 - else
188 - echo "Huh?"
189 - false
190 - fi
135 + check_result file1
136 +'
137 +
138 +test_expect_success 'same but with traditional patch input of depth 1' '
139 +
140 + cd "$D" &&
141 + git config apply.whitespace strip &&
142 + rm -f sub/file1 &&
143 + cp saved sub/file1 &&
144 + git update-index --refresh &&
145 +
146 + git apply -p0 gpatch-sub.file &&
147 + check_result sub/file1
148 +'
149 +
150 +test_expect_success 'same but with traditional patch input of depth 2' '
151 +
152 + cd "$D" &&
153 + git config apply.whitespace strip &&
154 + rm -f sub/file1 &&
155 + cp saved sub/file1 &&
156 + git update-index --refresh &&
157 +
158 + git apply gpatch-ab-sub.file &&
159 + check_result sub/file1
160 '
161
162 test_done