git-p4: recover from inconsistent perforce history
[git/debian.git] / t / t9600-cvsimport.sh
blob251fdd66c47b5e378cf091a47ba1f804eb74c487
1 #!/bin/sh
3 test_description='git cvsimport basic tests'
4 . ./lib-cvs.sh
6 if ! test_have_prereq NOT_ROOT; then
7 skip_all='When cvs is compiled with CVS_BADROOT commits as root fail'
8 test_done
9 fi
11 test_expect_success PERL 'setup cvsroot environment' '
12 CVSROOT=$(pwd)/cvsroot &&
13 export CVSROOT
16 test_expect_success PERL 'setup cvsroot' '$CVS init'
18 test_expect_success PERL 'setup a cvs module' '
20 mkdir "$CVSROOT/module" &&
21 $CVS co -d module-cvs module &&
22 (cd module-cvs &&
23 cat <<EOF >o_fortuna &&
24 O Fortuna
25 velut luna
26 statu variabilis,
28 semper crescis
29 aut decrescis;
30 vita detestabilis
32 nunc obdurat
33 et tunc curat
34 ludo mentis aciem,
36 egestatem,
37 potestatem
38 dissolvit ut glaciem.
39 EOF
40 $CVS add o_fortuna &&
41 cat <<EOF >message &&
42 add "O Fortuna" lyrics
44 These public domain lyrics make an excellent sample text.
45 EOF
46 $CVS commit -F message
50 test_expect_success PERL 'import a trivial module' '
52 git cvsimport -a -R -z 0 -C module-git module &&
53 test_cmp module-cvs/o_fortuna module-git/o_fortuna
57 test_expect_success PERL 'pack refs' '(cd module-git && git gc)'
59 test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
61 (cd module-git &&
62 git log --format="o_fortuna 1.1 %H" -1) > expected &&
63 test_cmp expected module-git/.git/cvs-revisions
66 test_expect_success PERL 'update cvs module' '
67 (cd module-cvs &&
68 cat <<EOF >o_fortuna &&
69 O Fortune,
70 like the moon
71 you are changeable,
73 ever waxing
74 and waning;
75 hateful life
77 first oppresses
78 and then soothes
79 as fancy takes it;
81 poverty
82 and power
83 it melts them like ice.
84 EOF
85 cat <<EOF >message &&
86 translate to English
88 My Latin is terrible.
89 EOF
90 $CVS commit -F message
94 test_expect_success PERL 'update git module' '
96 (cd module-git &&
97 git config cvsimport.trackRevisions true &&
98 git cvsimport -a -z 0 module &&
99 git merge origin
100 ) &&
101 test_cmp module-cvs/o_fortuna module-git/o_fortuna
105 test_expect_success PERL 'update has correct .git/cvs-revisions' '
107 (cd module-git &&
108 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
109 git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected &&
110 test_cmp expected module-git/.git/cvs-revisions
113 test_expect_success PERL 'update cvs module' '
115 (cd module-cvs &&
116 echo 1 >tick &&
117 $CVS add tick &&
118 $CVS commit -m 1
122 test_expect_success PERL 'cvsimport.module config works' '
124 (cd module-git &&
125 git config cvsimport.module module &&
126 git config cvsimport.trackRevisions true &&
127 git cvsimport -a -z0 &&
128 git merge origin
129 ) &&
130 test_cmp module-cvs/tick module-git/tick
134 test_expect_success PERL 'second update has correct .git/cvs-revisions' '
136 (cd module-git &&
137 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
138 git log --format="o_fortuna 1.2 %H" -1 HEAD^ &&
139 git log --format="tick 1.1 %H" -1 HEAD) > expected &&
140 test_cmp expected module-git/.git/cvs-revisions
143 test_expect_success PERL 'import from a CVS working tree' '
145 $CVS co -d import-from-wt module &&
146 (cd import-from-wt &&
147 git config cvsimport.trackRevisions false &&
148 git cvsimport -a -z0 &&
149 echo 1 >expect &&
150 git log -1 --pretty=format:%s%n >actual &&
151 test_cmp expect actual
156 test_expect_success PERL 'no .git/cvs-revisions created by default' '
158 ! test -e import-from-wt/.git/cvs-revisions
162 test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
164 test_done