Documentation/git-push: Explain status output in more detail
[git/jnareb-git.git] / t / t9401-git-cvsserver-crlf.sh
blob925bd0fbedf9865cef834460969c0a9fd2262437
1 #!/bin/sh
3 # Copyright (c) 2008 Matthew Ogilvie
4 # Parts adapted from other tests.
7 test_description='git-cvsserver -kb modes
9 tests -kb mode for binary files when accessing a git
10 repository using cvs CLI client via git-cvsserver server'
12 . ./test-lib.sh
14 marked_as () {
15 foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
16 if [ x"$foundEntry" = x"" ] ; then
17 echo "NOT FOUND: $1 $2 1 $3" >> "${WORKDIR}/marked.log"
18 return 1
20 test x"$(grep "^/$2/" "$1/CVS/Entries" | cut -d/ -f5)" = x"$3"
21 stat=$?
22 echo "$1 $2 $stat '$3'" >> "${WORKDIR}/marked.log"
23 return $stat
26 not_present() {
27 foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
28 if [ -r "$1/$2" ] ; then
29 echo "Error: File still exists: $1 $2" >> "${WORKDIR}/marked.log"
30 return 1;
32 if [ x"$foundEntry" != x"" ] ; then
33 echo "Error: should not have found: $1 $2" >> "${WORKDIR}/marked.log"
34 return 1;
35 else
36 echo "Correctly not found: $1 $2" >> "${WORKDIR}/marked.log"
37 return 0;
41 cvs >/dev/null 2>&1
42 if test $? -ne 1
43 then
44 skip_all='skipping git-cvsserver tests, cvs not found'
45 test_done
47 if ! test_have_prereq PERL
48 then
49 skip_all='skipping git-cvsserver tests, perl not available'
50 test_done
52 "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
53 skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
54 test_done
57 unset GIT_DIR GIT_CONFIG
58 WORKDIR=$(pwd)
59 SERVERDIR=$(pwd)/gitcvs.git
60 git_config="$SERVERDIR/config"
61 CVSROOT=":fork:$SERVERDIR"
62 CVSWORK="$(pwd)/cvswork"
63 CVS_SERVER=git-cvsserver
64 export CVSROOT CVS_SERVER
66 rm -rf "$CVSWORK" "$SERVERDIR"
67 test_expect_success 'setup' '
68 echo "Simple text file" >textfile.c &&
69 echo "File with embedded NUL: Q <- there" | q_to_nul > binfile.bin &&
70 mkdir subdir &&
71 echo "Another text file" > subdir/file.h &&
72 echo "Another binary: Q (this time CR)" | q_to_cr > subdir/withCr.bin &&
73 echo "Mixed up NUL, but marked text: Q <- there" | q_to_nul > mixedUp.c
74 echo "Unspecified" > subdir/unspecified.other &&
75 echo "/*.bin -crlf" > .gitattributes &&
76 echo "/*.c crlf" >> .gitattributes &&
77 echo "subdir/*.bin -crlf" >> .gitattributes &&
78 echo "subdir/*.c crlf" >> .gitattributes &&
79 echo "subdir/file.h crlf" >> .gitattributes &&
80 git add .gitattributes textfile.c binfile.bin mixedUp.c subdir/* &&
81 git commit -q -m "First Commit" &&
82 git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
83 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
84 GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
87 test_expect_success 'cvs co (default crlf)' '
88 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
89 test x"$(grep '/-k' cvswork/CVS/Entries cvswork/subdir/CVS/Entries)" = x""
92 rm -rf cvswork
93 test_expect_success 'cvs co (allbinary)' '
94 GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary true &&
95 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
96 marked_as cvswork textfile.c -kb &&
97 marked_as cvswork binfile.bin -kb &&
98 marked_as cvswork .gitattributes -kb &&
99 marked_as cvswork mixedUp.c -kb &&
100 marked_as cvswork/subdir withCr.bin -kb &&
101 marked_as cvswork/subdir file.h -kb &&
102 marked_as cvswork/subdir unspecified.other -kb
105 rm -rf cvswork cvs.log
106 test_expect_success 'cvs co (use attributes/allbinary)' '
107 GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr true &&
108 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
109 marked_as cvswork textfile.c "" &&
110 marked_as cvswork binfile.bin -kb &&
111 marked_as cvswork .gitattributes -kb &&
112 marked_as cvswork mixedUp.c "" &&
113 marked_as cvswork/subdir withCr.bin -kb &&
114 marked_as cvswork/subdir file.h "" &&
115 marked_as cvswork/subdir unspecified.other -kb
118 rm -rf cvswork
119 test_expect_success 'cvs co (use attributes)' '
120 GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary false &&
121 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
122 marked_as cvswork textfile.c "" &&
123 marked_as cvswork binfile.bin -kb &&
124 marked_as cvswork .gitattributes "" &&
125 marked_as cvswork mixedUp.c "" &&
126 marked_as cvswork/subdir withCr.bin -kb &&
127 marked_as cvswork/subdir file.h "" &&
128 marked_as cvswork/subdir unspecified.other ""
131 test_expect_success 'adding files' '
132 cd cvswork/subdir &&
133 echo "more text" > src.c &&
134 GIT_CONFIG="$git_config" cvs -Q add src.c >cvs.log 2>&1 &&
135 marked_as . src.c "" &&
136 echo "psuedo-binary" > temp.bin &&
137 cd .. &&
138 GIT_CONFIG="$git_config" cvs -Q add subdir/temp.bin >cvs.log 2>&1 &&
139 marked_as subdir temp.bin "-kb" &&
140 cd subdir &&
141 GIT_CONFIG="$git_config" cvs -Q ci -m "adding files" >cvs.log 2>&1 &&
142 marked_as . temp.bin "-kb" &&
143 marked_as . src.c ""
146 cd "$WORKDIR"
147 test_expect_success 'updating' '
148 git pull gitcvs.git &&
149 echo 'hi' > subdir/newfile.bin &&
150 echo 'junk' > subdir/file.h &&
151 echo 'hi' > subdir/newfile.c &&
152 echo 'hello' >> binfile.bin &&
153 git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&
154 git commit -q -m "Add and change some files" &&
155 git push gitcvs.git >/dev/null &&
156 cd cvswork &&
157 GIT_CONFIG="$git_config" cvs -Q update &&
158 cd .. &&
159 marked_as cvswork textfile.c "" &&
160 marked_as cvswork binfile.bin -kb &&
161 marked_as cvswork .gitattributes "" &&
162 marked_as cvswork mixedUp.c "" &&
163 marked_as cvswork/subdir withCr.bin -kb &&
164 marked_as cvswork/subdir file.h "" &&
165 marked_as cvswork/subdir unspecified.other "" &&
166 marked_as cvswork/subdir newfile.bin -kb &&
167 marked_as cvswork/subdir newfile.c "" &&
168 echo "File with embedded NUL: Q <- there" | q_to_nul > tmpExpect1 &&
169 echo "hello" >> tmpExpect1 &&
170 cmp cvswork/binfile.bin tmpExpect1
173 rm -rf cvswork
174 test_expect_success 'cvs co (use attributes/guess)' '
175 GIT_DIR="$SERVERDIR" git config gitcvs.allbinary guess &&
176 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
177 marked_as cvswork textfile.c "" &&
178 marked_as cvswork binfile.bin -kb &&
179 marked_as cvswork .gitattributes "" &&
180 marked_as cvswork mixedUp.c "" &&
181 marked_as cvswork/subdir withCr.bin -kb &&
182 marked_as cvswork/subdir file.h "" &&
183 marked_as cvswork/subdir unspecified.other "" &&
184 marked_as cvswork/subdir newfile.bin -kb &&
185 marked_as cvswork/subdir newfile.c ""
188 test_expect_success 'setup multi-line files' '
189 ( echo "line 1" &&
190 echo "line 2" &&
191 echo "line 3" &&
192 echo "line 4 with NUL: Q <-" ) | q_to_nul > multiline.c &&
193 git add multiline.c &&
194 ( echo "line 1" &&
195 echo "line 2" &&
196 echo "line 3" &&
197 echo "line 4" ) | q_to_nul > multilineTxt.c &&
198 git add multilineTxt.c &&
199 git commit -q -m "multiline files" &&
200 git push gitcvs.git >/dev/null
203 rm -rf cvswork
204 test_expect_success 'cvs co (guess)' '
205 GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr false &&
206 GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
207 marked_as cvswork textfile.c "" &&
208 marked_as cvswork binfile.bin -kb &&
209 marked_as cvswork .gitattributes "" &&
210 marked_as cvswork mixedUp.c -kb &&
211 marked_as cvswork multiline.c -kb &&
212 marked_as cvswork multilineTxt.c "" &&
213 marked_as cvswork/subdir withCr.bin -kb &&
214 marked_as cvswork/subdir file.h "" &&
215 marked_as cvswork/subdir unspecified.other "" &&
216 marked_as cvswork/subdir newfile.bin "" &&
217 marked_as cvswork/subdir newfile.c ""
220 test_expect_success 'cvs co another copy (guess)' '
221 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
222 marked_as cvswork2 textfile.c "" &&
223 marked_as cvswork2 binfile.bin -kb &&
224 marked_as cvswork2 .gitattributes "" &&
225 marked_as cvswork2 mixedUp.c -kb &&
226 marked_as cvswork2 multiline.c -kb &&
227 marked_as cvswork2 multilineTxt.c "" &&
228 marked_as cvswork2/subdir withCr.bin -kb &&
229 marked_as cvswork2/subdir file.h "" &&
230 marked_as cvswork2/subdir unspecified.other "" &&
231 marked_as cvswork2/subdir newfile.bin "" &&
232 marked_as cvswork2/subdir newfile.c ""
235 test_expect_success 'add text (guess)' '
236 cd cvswork &&
237 echo "simpleText" > simpleText.c &&
238 GIT_CONFIG="$git_config" cvs -Q add simpleText.c &&
239 cd .. &&
240 marked_as cvswork simpleText.c ""
243 test_expect_success 'add bin (guess)' '
244 cd cvswork &&
245 echo "simpleBin: NUL: Q <- there" | q_to_nul > simpleBin.bin &&
246 GIT_CONFIG="$git_config" cvs -Q add simpleBin.bin &&
247 cd .. &&
248 marked_as cvswork simpleBin.bin -kb
251 test_expect_success 'remove files (guess)' '
252 cd cvswork &&
253 GIT_CONFIG="$git_config" cvs -Q rm -f subdir/file.h &&
254 cd subdir &&
255 GIT_CONFIG="$git_config" cvs -Q rm -f withCr.bin &&
256 cd ../.. &&
257 marked_as cvswork/subdir withCr.bin -kb &&
258 marked_as cvswork/subdir file.h ""
261 test_expect_success 'cvs ci (guess)' '
262 cd cvswork &&
263 GIT_CONFIG="$git_config" cvs -Q ci -m "add/rm files" >cvs.log 2>&1 &&
264 cd .. &&
265 marked_as cvswork textfile.c "" &&
266 marked_as cvswork binfile.bin -kb &&
267 marked_as cvswork .gitattributes "" &&
268 marked_as cvswork mixedUp.c -kb &&
269 marked_as cvswork multiline.c -kb &&
270 marked_as cvswork multilineTxt.c "" &&
271 not_present cvswork/subdir withCr.bin &&
272 not_present cvswork/subdir file.h &&
273 marked_as cvswork/subdir unspecified.other "" &&
274 marked_as cvswork/subdir newfile.bin "" &&
275 marked_as cvswork/subdir newfile.c "" &&
276 marked_as cvswork simpleBin.bin -kb &&
277 marked_as cvswork simpleText.c ""
280 test_expect_success 'update subdir of other copy (guess)' '
281 cd cvswork2/subdir &&
282 GIT_CONFIG="$git_config" cvs -Q update &&
283 cd ../.. &&
284 marked_as cvswork2 textfile.c "" &&
285 marked_as cvswork2 binfile.bin -kb &&
286 marked_as cvswork2 .gitattributes "" &&
287 marked_as cvswork2 mixedUp.c -kb &&
288 marked_as cvswork2 multiline.c -kb &&
289 marked_as cvswork2 multilineTxt.c "" &&
290 not_present cvswork2/subdir withCr.bin &&
291 not_present cvswork2/subdir file.h &&
292 marked_as cvswork2/subdir unspecified.other "" &&
293 marked_as cvswork2/subdir newfile.bin "" &&
294 marked_as cvswork2/subdir newfile.c "" &&
295 not_present cvswork2 simpleBin.bin &&
296 not_present cvswork2 simpleText.c
299 echo "starting update/merge" >> "${WORKDIR}/marked.log"
300 test_expect_success 'update/merge full other copy (guess)' '
301 git pull gitcvs.git master &&
302 sed "s/3/replaced_3/" < multilineTxt.c > ml.temp &&
303 mv ml.temp multilineTxt.c &&
304 git add multilineTxt.c &&
305 git commit -q -m "modify multiline file" >> "${WORKDIR}/marked.log" &&
306 git push gitcvs.git >/dev/null &&
307 cd cvswork2 &&
308 sed "s/1/replaced_1/" < multilineTxt.c > ml.temp &&
309 mv ml.temp multilineTxt.c &&
310 GIT_CONFIG="$git_config" cvs update > cvs.log 2>&1 &&
311 cd .. &&
312 marked_as cvswork2 textfile.c "" &&
313 marked_as cvswork2 binfile.bin -kb &&
314 marked_as cvswork2 .gitattributes "" &&
315 marked_as cvswork2 mixedUp.c -kb &&
316 marked_as cvswork2 multiline.c -kb &&
317 marked_as cvswork2 multilineTxt.c "" &&
318 not_present cvswork2/subdir withCr.bin &&
319 not_present cvswork2/subdir file.h &&
320 marked_as cvswork2/subdir unspecified.other "" &&
321 marked_as cvswork2/subdir newfile.bin "" &&
322 marked_as cvswork2/subdir newfile.c "" &&
323 marked_as cvswork2 simpleBin.bin -kb &&
324 marked_as cvswork2 simpleText.c "" &&
325 echo "line replaced_1" > tmpExpect2 &&
326 echo "line 2" >> tmpExpect2 &&
327 echo "line replaced_3" >> tmpExpect2 &&
328 echo "line 4" | q_to_nul >> tmpExpect2 &&
329 cmp cvswork2/multilineTxt.c tmpExpect2
332 test_done