blob: 4c384ff02333e1413cc67b1b4a6bed47ae3d00db [file] [log] [blame]
Jeff King795c7c02007-11-28 13:55:46 -05001#!/bin/sh
2
Nanako Shiraishif9647322008-09-10 06:25:27 +09003test_description='git cvsimport basic tests'
Michael Haggerty535bb892009-02-23 06:08:10 +01004. ./lib-cvs.sh
Jeff King795c7c02007-11-28 13:55:46 -05005
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +00006test_expect_success PERL 'setup cvsroot environment' '
7 CVSROOT=$(pwd)/cvsroot &&
8 export CVSROOT
9'
Jeff King1b19ccd2009-04-03 15:33:59 -040010
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000011test_expect_success PERL 'setup cvsroot' '$CVS init'
Frank Lichtenheld40ae8872008-03-26 17:34:20 +000012
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000013test_expect_success PERL 'setup a cvs module' '
Jeff King795c7c02007-11-28 13:55:46 -050014
Bryan Donlanf69e8362008-05-04 01:37:59 -040015 mkdir "$CVSROOT/module" &&
Michael Haggerty161261b2009-02-23 06:08:11 +010016 $CVS co -d module-cvs module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020017 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050018 cat <<EOF >o_fortuna &&
19O Fortuna
20velut luna
21statu variabilis,
22
23semper crescis
24aut decrescis;
25vita detestabilis
26
27nunc obdurat
28et tunc curat
29ludo mentis aciem,
30
31egestatem,
32potestatem
33dissolvit ut glaciem.
34EOF
Michael Haggerty161261b2009-02-23 06:08:11 +010035 $CVS add o_fortuna &&
Jeff King795c7c02007-11-28 13:55:46 -050036 cat <<EOF >message &&
37add "O Fortuna" lyrics
38
39These public domain lyrics make an excellent sample text.
40EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020041 $CVS commit -F message
42 )
Jeff King795c7c02007-11-28 13:55:46 -050043'
44
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000045test_expect_success PERL 'import a trivial module' '
Jeff King795c7c02007-11-28 13:55:46 -050046
Aaron Crane0455ec02010-02-06 18:26:24 +000047 git cvsimport -a -R -z 0 -C module-git module &&
Junio C Hamano3af82862008-05-23 22:28:56 -070048 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -050049
50'
51
Junio C Hamano347c47e2010-09-06 16:46:36 -070052test_expect_success PERL 'pack refs' '(cd module-git && git gc)'
Jeff King9da0dab2007-11-28 13:56:11 -050053
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000054test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +000055
56 (cd module-git &&
57 git log --format="o_fortuna 1.1 %H" -1) > expected &&
58 test_cmp expected module-git/.git/cvs-revisions
59'
60
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000061test_expect_success PERL 'update cvs module' '
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020062 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050063 cat <<EOF >o_fortuna &&
64O Fortune,
65like the moon
66you are changeable,
67
68ever waxing
69and waning;
70hateful life
71
72first oppresses
73and then soothes
74as fancy takes it;
75
76poverty
77and power
78it melts them like ice.
79EOF
80 cat <<EOF >message &&
81translate to English
82
83My Latin is terrible.
84EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020085 $CVS commit -F message
86 )
Jeff King795c7c02007-11-28 13:55:46 -050087'
88
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000089test_expect_success PERL 'update git module' '
Jeff King795c7c02007-11-28 13:55:46 -050090
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020091 (cd module-git &&
Michael J Gruber60d59852010-12-29 22:55:34 +010092 git config cvsimport.trackRevisions true &&
93 git cvsimport -a -z 0 module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020094 git merge origin
95 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -070096 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -050097
98'
99
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000100test_expect_success PERL 'update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000101
102 (cd module-git &&
103 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
104 git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected &&
105 test_cmp expected module-git/.git/cvs-revisions
106'
107
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000108test_expect_success PERL 'update cvs module' '
Jeff King67d23242007-11-30 17:22:12 -0500109
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200110 (cd module-cvs &&
Jeff King67d23242007-11-30 17:22:12 -0500111 echo 1 >tick &&
Michael Haggerty161261b2009-02-23 06:08:11 +0100112 $CVS add tick &&
113 $CVS commit -m 1
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200114 )
Jeff King67d23242007-11-30 17:22:12 -0500115'
116
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000117test_expect_success PERL 'cvsimport.module config works' '
Jeff King67d23242007-11-30 17:22:12 -0500118
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200119 (cd module-git &&
Jeff King67d23242007-11-30 17:22:12 -0500120 git config cvsimport.module module &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100121 git config cvsimport.trackRevisions true &&
122 git cvsimport -a -z0 &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200123 git merge origin
124 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -0700125 test_cmp module-cvs/tick module-git/tick
Jeff King67d23242007-11-30 17:22:12 -0500126
127'
128
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000129test_expect_success PERL 'second update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000130
131 (cd module-git &&
132 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
133 git log --format="o_fortuna 1.2 %H" -1 HEAD^
134 git log --format="tick 1.1 %H" -1 HEAD) > expected &&
135 test_cmp expected module-git/.git/cvs-revisions
136'
137
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000138test_expect_success PERL 'import from a CVS working tree' '
Jeff King4e596e92007-12-02 12:22:19 -0500139
Michael Haggerty161261b2009-02-23 06:08:11 +0100140 $CVS co -d import-from-wt module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200141 (cd import-from-wt &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100142 git config cvsimport.trackRevisions false &&
Jeff King4e596e92007-12-02 12:22:19 -0500143 git cvsimport -a -z0 &&
144 echo 1 >expect &&
145 git log -1 --pretty=format:%s%n >actual &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200146 test_cmp actual expect
147 )
Jeff King4e596e92007-12-02 12:22:19 -0500148
149'
150
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000151test_expect_success PERL 'no .git/cvs-revisions created by default' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000152
153 ! test -e import-from-wt/.git/cvs-revisions
154
155'
156
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000157test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
Michael Haggertycefa3182009-02-23 06:08:12 +0100158
Jeff King795c7c02007-11-28 13:55:46 -0500159test_done