blob: 251fdd66c47b5e378cf091a47ba1f804eb74c487 [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ð Bjarmasona78d9252017-02-27 11:26:28 +00006if ! test_have_prereq NOT_ROOT; then
7 skip_all='When cvs is compiled with CVS_BADROOT commits as root fail'
8 test_done
9fi
10
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000011test_expect_success PERL 'setup cvsroot environment' '
12 CVSROOT=$(pwd)/cvsroot &&
13 export CVSROOT
14'
Jeff King1b19ccd2009-04-03 15:33:59 -040015
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000016test_expect_success PERL 'setup cvsroot' '$CVS init'
Frank Lichtenheld40ae8872008-03-26 17:34:20 +000017
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000018test_expect_success PERL 'setup a cvs module' '
Jeff King795c7c02007-11-28 13:55:46 -050019
Bryan Donlanf69e8362008-05-04 01:37:59 -040020 mkdir "$CVSROOT/module" &&
Michael Haggerty161261b2009-02-23 06:08:11 +010021 $CVS co -d module-cvs module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020022 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050023 cat <<EOF >o_fortuna &&
24O Fortuna
25velut luna
26statu variabilis,
27
28semper crescis
29aut decrescis;
30vita detestabilis
31
32nunc obdurat
33et tunc curat
34ludo mentis aciem,
35
36egestatem,
37potestatem
38dissolvit ut glaciem.
39EOF
Michael Haggerty161261b2009-02-23 06:08:11 +010040 $CVS add o_fortuna &&
Jeff King795c7c02007-11-28 13:55:46 -050041 cat <<EOF >message &&
42add "O Fortuna" lyrics
43
44These public domain lyrics make an excellent sample text.
45EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020046 $CVS commit -F message
47 )
Jeff King795c7c02007-11-28 13:55:46 -050048'
49
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000050test_expect_success PERL 'import a trivial module' '
Jeff King795c7c02007-11-28 13:55:46 -050051
Aaron Crane0455ec02010-02-06 18:26:24 +000052 git cvsimport -a -R -z 0 -C module-git module &&
Junio C Hamano3af82862008-05-23 22:28:56 -070053 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -050054
55'
56
Junio C Hamano347c47e2010-09-06 16:46:36 -070057test_expect_success PERL 'pack refs' '(cd module-git && git gc)'
Jeff King9da0dab2007-11-28 13:56:11 -050058
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000059test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +000060
61 (cd module-git &&
62 git log --format="o_fortuna 1.1 %H" -1) > expected &&
63 test_cmp expected module-git/.git/cvs-revisions
64'
65
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000066test_expect_success PERL 'update cvs module' '
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020067 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050068 cat <<EOF >o_fortuna &&
69O Fortune,
70like the moon
71you are changeable,
72
73ever waxing
74and waning;
75hateful life
76
77first oppresses
78and then soothes
79as fancy takes it;
80
81poverty
82and power
83it melts them like ice.
84EOF
85 cat <<EOF >message &&
86translate to English
87
88My Latin is terrible.
89EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020090 $CVS commit -F message
91 )
Jeff King795c7c02007-11-28 13:55:46 -050092'
93
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000094test_expect_success PERL 'update git module' '
Jeff King795c7c02007-11-28 13:55:46 -050095
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020096 (cd module-git &&
Michael J Gruber60d59852010-12-29 22:55:34 +010097 git config cvsimport.trackRevisions true &&
98 git cvsimport -a -z 0 module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020099 git merge origin
100 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -0700101 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -0500102
103'
104
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000105test_expect_success PERL 'update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000106
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
111'
112
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000113test_expect_success PERL 'update cvs module' '
Jeff King67d23242007-11-30 17:22:12 -0500114
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200115 (cd module-cvs &&
Jeff King67d23242007-11-30 17:22:12 -0500116 echo 1 >tick &&
Michael Haggerty161261b2009-02-23 06:08:11 +0100117 $CVS add tick &&
118 $CVS commit -m 1
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200119 )
Jeff King67d23242007-11-30 17:22:12 -0500120'
121
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000122test_expect_success PERL 'cvsimport.module config works' '
Jeff King67d23242007-11-30 17:22:12 -0500123
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200124 (cd module-git &&
Jeff King67d23242007-11-30 17:22:12 -0500125 git config cvsimport.module module &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100126 git config cvsimport.trackRevisions true &&
127 git cvsimport -a -z0 &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200128 git merge origin
129 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -0700130 test_cmp module-cvs/tick module-git/tick
Jeff King67d23242007-11-30 17:22:12 -0500131
132'
133
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000134test_expect_success PERL 'second update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000135
136 (cd module-git &&
137 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
Eric Sunshinecff42432018-07-01 20:24:04 -0400138 git log --format="o_fortuna 1.2 %H" -1 HEAD^ &&
Aaron Crane0455ec02010-02-06 18:26:24 +0000139 git log --format="tick 1.1 %H" -1 HEAD) > expected &&
140 test_cmp expected module-git/.git/cvs-revisions
141'
142
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000143test_expect_success PERL 'import from a CVS working tree' '
Jeff King4e596e92007-12-02 12:22:19 -0500144
Michael Haggerty161261b2009-02-23 06:08:11 +0100145 $CVS co -d import-from-wt module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200146 (cd import-from-wt &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100147 git config cvsimport.trackRevisions false &&
Jeff King4e596e92007-12-02 12:22:19 -0500148 git cvsimport -a -z0 &&
149 echo 1 >expect &&
150 git log -1 --pretty=format:%s%n >actual &&
Matthew DeVoredcbaa0b2018-10-05 14:54:04 -0700151 test_cmp expect actual
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200152 )
Jeff King4e596e92007-12-02 12:22:19 -0500153
154'
155
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000156test_expect_success PERL 'no .git/cvs-revisions created by default' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000157
158 ! test -e import-from-wt/.git/cvs-revisions
159
160'
161
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000162test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree master'
Michael Haggertycefa3182009-02-23 06:08:12 +0100163
Jeff King795c7c02007-11-28 13:55:46 -0500164test_done