blob: 41fcf3606b39b793cb38e41c9bdd90a4d9fe3e4b [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'
Johannes Schindelin765577b2020-11-18 23:44:43 +00004GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +00005export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
Patrick Steinhardtfba95da2024-05-27 13:45:52 +02007TEST_PASSES_SANITIZE_LEAK=true
Michael Haggerty535bb892009-02-23 06:08:10 +01008. ./lib-cvs.sh
Jeff King795c7c02007-11-28 13:55:46 -05009
Ævar Arnfjörð Bjarmasona78d9252017-02-27 11:26:28 +000010if ! test_have_prereq NOT_ROOT; then
11 skip_all='When cvs is compiled with CVS_BADROOT commits as root fail'
12 test_done
13fi
14
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000015test_expect_success PERL 'setup cvsroot environment' '
16 CVSROOT=$(pwd)/cvsroot &&
17 export CVSROOT
18'
Jeff King1b19ccd2009-04-03 15:33:59 -040019
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000020test_expect_success PERL 'setup cvsroot' '$CVS init'
Frank Lichtenheld40ae8872008-03-26 17:34:20 +000021
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000022test_expect_success PERL 'setup a cvs module' '
Jeff King795c7c02007-11-28 13:55:46 -050023
Bryan Donlanf69e8362008-05-04 01:37:59 -040024 mkdir "$CVSROOT/module" &&
Michael Haggerty161261b2009-02-23 06:08:11 +010025 $CVS co -d module-cvs module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020026 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050027 cat <<EOF >o_fortuna &&
28O Fortuna
29velut luna
30statu variabilis,
31
32semper crescis
33aut decrescis;
34vita detestabilis
35
36nunc obdurat
37et tunc curat
38ludo mentis aciem,
39
40egestatem,
41potestatem
42dissolvit ut glaciem.
43EOF
Michael Haggerty161261b2009-02-23 06:08:11 +010044 $CVS add o_fortuna &&
Jeff King795c7c02007-11-28 13:55:46 -050045 cat <<EOF >message &&
46add "O Fortuna" lyrics
47
48These public domain lyrics make an excellent sample text.
49EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020050 $CVS commit -F message
51 )
Jeff King795c7c02007-11-28 13:55:46 -050052'
53
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000054test_expect_success PERL 'import a trivial module' '
Jeff King795c7c02007-11-28 13:55:46 -050055
Aaron Crane0455ec02010-02-06 18:26:24 +000056 git cvsimport -a -R -z 0 -C module-git module &&
Junio C Hamano3af82862008-05-23 22:28:56 -070057 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -050058
59'
60
Junio C Hamano347c47e2010-09-06 16:46:36 -070061test_expect_success PERL 'pack refs' '(cd module-git && git gc)'
Jeff King9da0dab2007-11-28 13:56:11 -050062
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000063test_expect_success PERL 'initial import has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +000064
65 (cd module-git &&
66 git log --format="o_fortuna 1.1 %H" -1) > expected &&
67 test_cmp expected module-git/.git/cvs-revisions
68'
69
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000070test_expect_success PERL 'update cvs module' '
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020071 (cd module-cvs &&
Jeff King795c7c02007-11-28 13:55:46 -050072 cat <<EOF >o_fortuna &&
73O Fortune,
74like the moon
75you are changeable,
76
77ever waxing
78and waning;
79hateful life
80
81first oppresses
82and then soothes
83as fancy takes it;
84
85poverty
86and power
87it melts them like ice.
88EOF
89 cat <<EOF >message &&
90translate to English
91
92My Latin is terrible.
93EOF
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +020094 $CVS commit -F message
95 )
Jeff King795c7c02007-11-28 13:55:46 -050096'
97
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +000098test_expect_success PERL 'update git module' '
Jeff King795c7c02007-11-28 13:55:46 -050099
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200100 (cd module-git &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100101 git config cvsimport.trackRevisions true &&
102 git cvsimport -a -z 0 module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200103 git merge origin
104 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -0700105 test_cmp module-cvs/o_fortuna module-git/o_fortuna
Jeff King795c7c02007-11-28 13:55:46 -0500106
107'
108
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000109test_expect_success PERL 'update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000110
111 (cd module-git &&
112 git log --format="o_fortuna 1.1 %H" -1 HEAD^ &&
113 git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected &&
114 test_cmp expected module-git/.git/cvs-revisions
115'
116
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000117test_expect_success PERL 'update cvs module' '
Jeff King67d23242007-11-30 17:22:12 -0500118
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200119 (cd module-cvs &&
Jeff King67d23242007-11-30 17:22:12 -0500120 echo 1 >tick &&
Michael Haggerty161261b2009-02-23 06:08:11 +0100121 $CVS add tick &&
122 $CVS commit -m 1
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200123 )
Jeff King67d23242007-11-30 17:22:12 -0500124'
125
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000126test_expect_success PERL 'cvsimport.module config works' '
Jeff King67d23242007-11-30 17:22:12 -0500127
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200128 (cd module-git &&
Jeff King67d23242007-11-30 17:22:12 -0500129 git config cvsimport.module module &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100130 git config cvsimport.trackRevisions true &&
131 git cvsimport -a -z0 &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200132 git merge origin
133 ) &&
Junio C Hamano3af82862008-05-23 22:28:56 -0700134 test_cmp module-cvs/tick module-git/tick
Jeff King67d23242007-11-30 17:22:12 -0500135
136'
137
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000138test_expect_success PERL 'second update has correct .git/cvs-revisions' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000139
140 (cd module-git &&
141 git log --format="o_fortuna 1.1 %H" -1 HEAD^^ &&
Eric Sunshinecff42432018-07-01 20:24:04 -0400142 git log --format="o_fortuna 1.2 %H" -1 HEAD^ &&
Aaron Crane0455ec02010-02-06 18:26:24 +0000143 git log --format="tick 1.1 %H" -1 HEAD) > expected &&
144 test_cmp expected module-git/.git/cvs-revisions
145'
146
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000147test_expect_success PERL 'import from a CVS working tree' '
Jeff King4e596e92007-12-02 12:22:19 -0500148
Michael Haggerty161261b2009-02-23 06:08:11 +0100149 $CVS co -d import-from-wt module &&
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200150 (cd import-from-wt &&
Michael J Gruber60d59852010-12-29 22:55:34 +0100151 git config cvsimport.trackRevisions false &&
Jeff King4e596e92007-12-02 12:22:19 -0500152 git cvsimport -a -z0 &&
153 echo 1 >expect &&
154 git log -1 --pretty=format:%s%n >actual &&
Matthew DeVoredcbaa0b2018-10-05 14:54:04 -0700155 test_cmp expect actual
Jens Lehmannfd4ec4f2010-09-06 20:39:54 +0200156 )
Jeff King4e596e92007-12-02 12:22:19 -0500157
158'
159
Ævar Arnfjörð Bjarmason900eab42010-08-13 20:40:07 +0000160test_expect_success PERL 'no .git/cvs-revisions created by default' '
Aaron Crane0455ec02010-02-06 18:26:24 +0000161
162 ! test -e import-from-wt/.git/cvs-revisions
163
164'
165
Johannes Schindelin765577b2020-11-18 23:44:43 +0000166test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree main'
Michael Haggertycefa3182009-02-23 06:08:12 +0100167
Jeff King795c7c02007-11-28 13:55:46 -0500168test_done