clone: disconnect transport after fetching
[git] / t / t9600-cvsimport.sh
1 #!/bin/sh
2
3 test_description='git cvsimport basic tests'
4 . ./test-lib.sh
5
6 CVSROOT=$(pwd)/cvsroot
7 export CVSROOT
8 unset CVS_SERVER
9 # for clean cvsps cache
10 HOME=$(pwd)
11 export HOME
12
13 if ! type cvs >/dev/null 2>&1
14 then
15         say 'skipping cvsimport tests, cvs not found'
16         test_done
17         exit
18 fi
19
20 cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
21 case "$cvsps_version" in
22 2.1 | 2.2*)
23         ;;
24 '')
25         say 'skipping cvsimport tests, cvsps not found'
26         test_done
27         exit
28         ;;
29 *)
30         say 'skipping cvsimport tests, unsupported cvsps version'
31         test_done
32         exit
33         ;;
34 esac
35
36 test_expect_success 'setup cvsroot' 'cvs init'
37
38 test_expect_success 'setup a cvs module' '
39
40         mkdir "$CVSROOT/module" &&
41         cvs co -d module-cvs module &&
42         cd module-cvs &&
43         cat <<EOF >o_fortuna &&
44 O Fortuna
45 velut luna
46 statu variabilis,
47
48 semper crescis
49 aut decrescis;
50 vita detestabilis
51
52 nunc obdurat
53 et tunc curat
54 ludo mentis aciem,
55
56 egestatem,
57 potestatem
58 dissolvit ut glaciem.
59 EOF
60         cvs add o_fortuna &&
61         cat <<EOF >message &&
62 add "O Fortuna" lyrics
63
64 These public domain lyrics make an excellent sample text.
65 EOF
66         cvs commit -F message &&
67         cd ..
68 '
69
70 test_expect_success 'import a trivial module' '
71
72         git cvsimport -a -z 0 -C module-git module &&
73         test_cmp module-cvs/o_fortuna module-git/o_fortuna
74
75 '
76
77 test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
78
79 test_expect_success 'update cvs module' '
80
81         cd module-cvs &&
82         cat <<EOF >o_fortuna &&
83 O Fortune,
84 like the moon
85 you are changeable,
86
87 ever waxing
88 and waning;
89 hateful life
90
91 first oppresses
92 and then soothes
93 as fancy takes it;
94
95 poverty
96 and power
97 it melts them like ice.
98 EOF
99         cat <<EOF >message &&
100 translate to English
101
102 My Latin is terrible.
103 EOF
104         cvs commit -F message &&
105         cd ..
106 '
107
108 test_expect_success 'update git module' '
109
110         cd module-git &&
111         git cvsimport -a -z 0 module &&
112         git merge origin &&
113         cd .. &&
114         test_cmp module-cvs/o_fortuna module-git/o_fortuna
115
116 '
117
118 test_expect_success 'update cvs module' '
119
120         cd module-cvs &&
121                 echo 1 >tick &&
122                 cvs add tick &&
123                 cvs commit -m 1
124         cd ..
125
126 '
127
128 test_expect_success 'cvsimport.module config works' '
129
130         cd module-git &&
131                 git config cvsimport.module module &&
132                 git cvsimport -a -z0 &&
133                 git merge origin &&
134         cd .. &&
135         test_cmp module-cvs/tick module-git/tick
136
137 '
138
139 test_expect_success 'import from a CVS working tree' '
140
141         cvs co -d import-from-wt module &&
142         cd import-from-wt &&
143                 git cvsimport -a -z0 &&
144                 echo 1 >expect &&
145                 git log -1 --pretty=format:%s%n >actual &&
146                 test_cmp actual expect &&
147         cd ..
148
149 '
150
151 test_done