t2004: modernize style

In particular: * indent test body * place test description on same line as test_expect_* * place closing quote on its own line * name output file "actual" rather than "out" * name setup test "setup" rather than "preparation" Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Dec 24, 2014 at 04:43 UTC 9fb7b57f8272a38747d49fe8ecee2e20bb887570
1 file changed +196 -195
t/t2004-checkout-cache-temp.sh
+196 -195
@@ -10,202 +10,203 @@ rather than the tracked path.'
10
11 . ./test-lib.sh
12
13 -test_expect_success \
14 -'preparation' '
15 -mkdir asubdir &&
16 -echo tree1path0 >path0 &&
17 -echo tree1path1 >path1 &&
18 -echo tree1path3 >path3 &&
19 -echo tree1path4 >path4 &&
20 -echo tree1asubdir/path5 >asubdir/path5 &&
21 -git update-index --add path0 path1 path3 path4 asubdir/path5 &&
22 -t1=$(git write-tree) &&
23 -rm -f path* .merge_* out .git/index &&
24 -echo tree2path0 >path0 &&
25 -echo tree2path1 >path1 &&
26 -echo tree2path2 >path2 &&
27 -echo tree2path4 >path4 &&
28 -git update-index --add path0 path1 path2 path4 &&
29 -t2=$(git write-tree) &&
30 -rm -f path* .merge_* out .git/index &&
31 -echo tree2path0 >path0 &&
32 -echo tree3path1 >path1 &&
33 -echo tree3path2 >path2 &&
34 -echo tree3path3 >path3 &&
35 -git update-index --add path0 path1 path2 path3 &&
36 -t3=$(git write-tree)'
37 -
38 -test_expect_success \
39 -'checkout one stage 0 to temporary file' '
40 -rm -f path* .merge_* out .git/index &&
41 -git read-tree $t1 &&
42 -git checkout-index --temp -- path1 >out &&
43 -test_line_count = 1 out &&
44 -test $(cut "-d " -f2 out) = path1 &&
45 -p=$(cut "-d " -f1 out) &&
46 -test -f $p &&
47 -test $(cat $p) = tree1path1'
48 -
49 -test_expect_success \
50 -'checkout all stage 0 to temporary files' '
51 -rm -f path* .merge_* out .git/index &&
52 -git read-tree $t1 &&
53 -git checkout-index -a --temp >out &&
54 -test_line_count = 5 out &&
55 -for f in path0 path1 path3 path4 asubdir/path5
56 -do
57 - test $(grep $f out | cut "-d " -f2) = $f &&
58 - p=$(grep $f out | cut "-d " -f1) &&
13 +test_expect_success 'setup' '
14 + mkdir asubdir &&
15 + echo tree1path0 >path0 &&
16 + echo tree1path1 >path1 &&
17 + echo tree1path3 >path3 &&
18 + echo tree1path4 >path4 &&
19 + echo tree1asubdir/path5 >asubdir/path5 &&
20 + git update-index --add path0 path1 path3 path4 asubdir/path5 &&
21 + t1=$(git write-tree) &&
22 + rm -f path* .merge_* actual .git/index &&
23 + echo tree2path0 >path0 &&
24 + echo tree2path1 >path1 &&
25 + echo tree2path2 >path2 &&
26 + echo tree2path4 >path4 &&
27 + git update-index --add path0 path1 path2 path4 &&
28 + t2=$(git write-tree) &&
29 + rm -f path* .merge_* actual .git/index &&
30 + echo tree2path0 >path0 &&
31 + echo tree3path1 >path1 &&
32 + echo tree3path2 >path2 &&
33 + echo tree3path3 >path3 &&
34 + git update-index --add path0 path1 path2 path3 &&
35 + t3=$(git write-tree)
36 +'
37 +
38 +test_expect_success 'checkout one stage 0 to temporary file' '
39 + rm -f path* .merge_* actual .git/index &&
40 + git read-tree $t1 &&
41 + git checkout-index --temp -- path1 >actual &&
42 + test_line_count = 1 actual &&
43 + test $(cut "-d " -f2 actual) = path1 &&
44 + p=$(cut "-d " -f1 actual) &&
45 test -f $p &&
60 - test $(cat $p) = tree1$f
61 -done'
62 -
63 -test_expect_success \
64 -'prepare 3-way merge' '
65 -rm -f path* .merge_* out .git/index &&
66 -git read-tree -m $t1 $t2 $t3'
67 -
68 -test_expect_success \
69 -'checkout one stage 2 to temporary file' '
70 -rm -f path* .merge_* out &&
71 -git checkout-index --stage=2 --temp -- path1 >out &&
72 -test_line_count = 1 out &&
73 -test $(cut "-d " -f2 out) = path1 &&
74 -p=$(cut "-d " -f1 out) &&
75 -test -f $p &&
76 -test $(cat $p) = tree2path1'
77 -
78 -test_expect_success \
79 -'checkout all stage 2 to temporary files' '
80 -rm -f path* .merge_* out &&
81 -git checkout-index --all --stage=2 --temp >out &&
82 -test_line_count = 3 out &&
83 -for f in path1 path2 path4
84 -do
85 - test $(grep $f out | cut "-d " -f2) = $f &&
86 - p=$(grep $f out | cut "-d " -f1) &&
46 + test $(cat $p) = tree1path1
47 +'
48 +
49 +test_expect_success 'checkout all stage 0 to temporary files' '
50 + rm -f path* .merge_* actual .git/index &&
51 + git read-tree $t1 &&
52 + git checkout-index -a --temp >actual &&
53 + test_line_count = 5 actual &&
54 + for f in path0 path1 path3 path4 asubdir/path5
55 + do
56 + test $(grep $f actual | cut "-d " -f2) = $f &&
57 + p=$(grep $f actual | cut "-d " -f1) &&
58 + test -f $p &&
59 + test $(cat $p) = tree1$f
60 + done
61 +'
62 +
63 +test_expect_success 'setup 3-way merge' '
64 + rm -f path* .merge_* actual .git/index &&
65 + git read-tree -m $t1 $t2 $t3
66 +'
67 +
68 +test_expect_success 'checkout one stage 2 to temporary file' '
69 + rm -f path* .merge_* actual &&
70 + git checkout-index --stage=2 --temp -- path1 >actual &&
71 + test_line_count = 1 actual &&
72 + test $(cut "-d " -f2 actual) = path1 &&
73 + p=$(cut "-d " -f1 actual) &&
74 test -f $p &&
88 - test $(cat $p) = tree2$f
89 -done'
90 -
91 -test_expect_success \
92 -'checkout all stages/one file to nothing' '
93 -rm -f path* .merge_* out &&
94 -git checkout-index --stage=all --temp -- path0 >out &&
95 -test_line_count = 0 out'
96 -
97 -test_expect_success \
98 -'checkout all stages/one file to temporary files' '
99 -rm -f path* .merge_* out &&
100 -git checkout-index --stage=all --temp -- path1 >out &&
101 -test_line_count = 1 out &&
102 -test $(cut "-d " -f2 out) = path1 &&
103 -cut "-d " -f1 out | (read s1 s2 s3 &&
104 -test -f $s1 &&
105 -test -f $s2 &&
106 -test -f $s3 &&
107 -test $(cat $s1) = tree1path1 &&
108 -test $(cat $s2) = tree2path1 &&
109 -test $(cat $s3) = tree3path1)'
110 -
111 -test_expect_success \
112 -'checkout some stages/one file to temporary files' '
113 -rm -f path* .merge_* out &&
114 -git checkout-index --stage=all --temp -- path2 >out &&
115 -test_line_count = 1 out &&
116 -test $(cut "-d " -f2 out) = path2 &&
117 -cut "-d " -f1 out | (read s1 s2 s3 &&
118 -test $s1 = . &&
119 -test -f $s2 &&
120 -test -f $s3 &&
121 -test $(cat $s2) = tree2path2 &&
122 -test $(cat $s3) = tree3path2)'
123 -
124 -test_expect_success \
125 -'checkout all stages/all files to temporary files' '
126 -rm -f path* .merge_* out &&
127 -git checkout-index -a --stage=all --temp >out &&
128 -test_line_count = 5 out'
129 -
130 -test_expect_success \
131 -'-- path0: no entry' '
132 -test x$(grep path0 out | cut "-d " -f2) = x'
133 -
134 -test_expect_success \
135 -'-- path1: all 3 stages' '
136 -test $(grep path1 out | cut "-d " -f2) = path1 &&
137 -grep path1 out | cut "-d " -f1 | (read s1 s2 s3 &&
138 -test -f $s1 &&
139 -test -f $s2 &&
140 -test -f $s3 &&
141 -test $(cat $s1) = tree1path1 &&
142 -test $(cat $s2) = tree2path1 &&
143 -test $(cat $s3) = tree3path1)'
144 -
145 -test_expect_success \
146 -'-- path2: no stage 1, have stage 2 and 3' '
147 -test $(grep path2 out | cut "-d " -f2) = path2 &&
148 -grep path2 out | cut "-d " -f1 | (read s1 s2 s3 &&
149 -test $s1 = . &&
150 -test -f $s2 &&
151 -test -f $s3 &&
152 -test $(cat $s2) = tree2path2 &&
153 -test $(cat $s3) = tree3path2)'
154 -
155 -test_expect_success \
156 -'-- path3: no stage 2, have stage 1 and 3' '
157 -test $(grep path3 out | cut "-d " -f2) = path3 &&
158 -grep path3 out | cut "-d " -f1 | (read s1 s2 s3 &&
159 -test -f $s1 &&
160 -test $s2 = . &&
161 -test -f $s3 &&
162 -test $(cat $s1) = tree1path3 &&
163 -test $(cat $s3) = tree3path3)'
164 -
165 -test_expect_success \
166 -'-- path4: no stage 3, have stage 1 and 3' '
167 -test $(grep path4 out | cut "-d " -f2) = path4 &&
168 -grep path4 out | cut "-d " -f1 | (read s1 s2 s3 &&
169 -test -f $s1 &&
170 -test -f $s2 &&
171 -test $s3 = . &&
172 -test $(cat $s1) = tree1path4 &&
173 -test $(cat $s2) = tree2path4)'
174 -
175 -test_expect_success \
176 -'-- asubdir/path5: no stage 2 and 3 have stage 1' '
177 -test $(grep asubdir/path5 out | cut "-d " -f2) = asubdir/path5 &&
178 -grep asubdir/path5 out | cut "-d " -f1 | (read s1 s2 s3 &&
179 -test -f $s1 &&
180 -test $s2 = . &&
181 -test $s3 = . &&
182 -test $(cat $s1) = tree1asubdir/path5)'
183 -
184 -test_expect_success \
185 -'checkout --temp within subdir' '
186 -(cd asubdir &&
187 - git checkout-index -a --stage=all >out &&
188 - test_line_count = 1 out &&
189 - test $(grep path5 out | cut "-d " -f2) = path5 &&
190 - grep path5 out | cut "-d " -f1 | (read s1 s2 s3 &&
191 - test -f ../$s1 &&
192 - test $s2 = . &&
193 - test $s3 = . &&
194 - test $(cat ../$s1) = tree1asubdir/path5)
195 -)'
196 -
197 -test_expect_success \
198 -'checkout --temp symlink' '
199 -rm -f path* .merge_* out .git/index &&
200 -test_ln_s_add b a &&
201 -t4=$(git write-tree) &&
202 -rm -f .git/index &&
203 -git read-tree $t4 &&
204 -git checkout-index --temp -a >out &&
205 -test_line_count = 1 out &&
206 -test $(cut "-d " -f2 out) = a &&
207 -p=$(cut "-d " -f1 out) &&
208 -test -f $p &&
209 -test $(cat $p) = b'
75 + test $(cat $p) = tree2path1
76 +'
77 +
78 +test_expect_success 'checkout all stage 2 to temporary files' '
79 + rm -f path* .merge_* actual &&
80 + git checkout-index --all --stage=2 --temp >actual &&
81 + test_line_count = 3 actual &&
82 + for f in path1 path2 path4
83 + do
84 + test $(grep $f actual | cut "-d " -f2) = $f &&
85 + p=$(grep $f actual | cut "-d " -f1) &&
86 + test -f $p &&
87 + test $(cat $p) = tree2$f
88 + done
89 +'
90 +
91 +test_expect_success 'checkout all stages/one file to nothing' '
92 + rm -f path* .merge_* actual &&
93 + git checkout-index --stage=all --temp -- path0 >actual &&
94 + test_line_count = 0 actual
95 +'
96 +
97 +test_expect_success 'checkout all stages/one file to temporary files' '
98 + rm -f path* .merge_* actual &&
99 + git checkout-index --stage=all --temp -- path1 >actual &&
100 + test_line_count = 1 actual &&
101 + test $(cut "-d " -f2 actual) = path1 &&
102 + cut "-d " -f1 actual | (read s1 s2 s3 &&
103 + test -f $s1 &&
104 + test -f $s2 &&
105 + test -f $s3 &&
106 + test $(cat $s1) = tree1path1 &&
107 + test $(cat $s2) = tree2path1 &&
108 + test $(cat $s3) = tree3path1)
109 +'
110 +
111 +test_expect_success 'checkout some stages/one file to temporary files' '
112 + rm -f path* .merge_* actual &&
113 + git checkout-index --stage=all --temp -- path2 >actual &&
114 + test_line_count = 1 actual &&
115 + test $(cut "-d " -f2 actual) = path2 &&
116 + cut "-d " -f1 actual | (read s1 s2 s3 &&
117 + test $s1 = . &&
118 + test -f $s2 &&
119 + test -f $s3 &&
120 + test $(cat $s2) = tree2path2 &&
121 + test $(cat $s3) = tree3path2)
122 +'
123 +
124 +test_expect_success 'checkout all stages/all files to temporary files' '
125 + rm -f path* .merge_* actual &&
126 + git checkout-index -a --stage=all --temp >actual &&
127 + test_line_count = 5 actual
128 +'
129 +
130 +test_expect_success '-- path0: no entry' '
131 + test x$(grep path0 actual | cut "-d " -f2) = x
132 +'
133 +
134 +test_expect_success '-- path1: all 3 stages' '
135 + test $(grep path1 actual | cut "-d " -f2) = path1 &&
136 + grep path1 actual | cut "-d " -f1 | (read s1 s2 s3 &&
137 + test -f $s1 &&
138 + test -f $s2 &&
139 + test -f $s3 &&
140 + test $(cat $s1) = tree1path1 &&
141 + test $(cat $s2) = tree2path1 &&
142 + test $(cat $s3) = tree3path1)
143 +'
144 +
145 +test_expect_success '-- path2: no stage 1, have stage 2 and 3' '
146 + test $(grep path2 actual | cut "-d " -f2) = path2 &&
147 + grep path2 actual | cut "-d " -f1 | (read s1 s2 s3 &&
148 + test $s1 = . &&
149 + test -f $s2 &&
150 + test -f $s3 &&
151 + test $(cat $s2) = tree2path2 &&
152 + test $(cat $s3) = tree3path2)
153 +'
154 +
155 +test_expect_success '-- path3: no stage 2, have stage 1 and 3' '
156 + test $(grep path3 actual | cut "-d " -f2) = path3 &&
157 + grep path3 actual | cut "-d " -f1 | (read s1 s2 s3 &&
158 + test -f $s1 &&
159 + test $s2 = . &&
160 + test -f $s3 &&
161 + test $(cat $s1) = tree1path3 &&
162 + test $(cat $s3) = tree3path3)
163 +'
164 +
165 +test_expect_success '-- path4: no stage 3, have stage 1 and 3' '
166 + test $(grep path4 actual | cut "-d " -f2) = path4 &&
167 + grep path4 actual | cut "-d " -f1 | (read s1 s2 s3 &&
168 + test -f $s1 &&
169 + test -f $s2 &&
170 + test $s3 = . &&
171 + test $(cat $s1) = tree1path4 &&
172 + test $(cat $s2) = tree2path4)
173 +'
174 +
175 +test_expect_success '-- asubdir/path5: no stage 2 and 3 have stage 1' '
176 + test $(grep asubdir/path5 actual | cut "-d " -f2) = asubdir/path5 &&
177 + grep asubdir/path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
178 + test -f $s1 &&
179 + test $s2 = . &&
180 + test $s3 = . &&
181 + test $(cat $s1) = tree1asubdir/path5)
182 +'
183 +
184 +test_expect_success 'checkout --temp within subdir' '
185 + (
186 + cd asubdir &&
187 + git checkout-index -a --stage=all >actual &&
188 + test_line_count = 1 actual &&
189 + test $(grep path5 actual | cut "-d " -f2) = path5 &&
190 + grep path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
191 + test -f ../$s1 &&
192 + test $s2 = . &&
193 + test $s3 = . &&
194 + test $(cat ../$s1) = tree1asubdir/path5)
195 + )
196 +'
197 +
198 +test_expect_success 'checkout --temp symlink' '
199 + rm -f path* .merge_* actual .git/index &&
200 + test_ln_s_add b a &&
201 + t4=$(git write-tree) &&
202 + rm -f .git/index &&
203 + git read-tree $t4 &&
204 + git checkout-index --temp -a >actual &&
205 + test_line_count = 1 actual &&
206 + test $(cut "-d " -f2 actual) = a &&
207 + p=$(cut "-d " -f1 actual) &&
208 + test -f $p &&
209 + test $(cat $p) = b
210 +'
211
212 test_done