Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Nanako Shiraishi | f964732 | 2008-09-10 06:25:27 +0900 | [diff] [blame] | 3 | test_description='git cvsimport basic tests' |
Johannes Schindelin | 765577b | 2020-11-18 23:44:43 +0000 | [diff] [blame] | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
Patrick Steinhardt | fba95da | 2024-05-27 13:45:52 +0200 | [diff] [blame] | 7 | TEST_PASSES_SANITIZE_LEAK=true |
Michael Haggerty | 535bb89 | 2009-02-23 06:08:10 +0100 | [diff] [blame] | 8 | . ./lib-cvs.sh |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 9 | |
Ævar Arnfjörð Bjarmason | a78d925 | 2017-02-27 11:26:28 +0000 | [diff] [blame] | 10 | if ! test_have_prereq NOT_ROOT; then |
| 11 | skip_all='When cvs is compiled with CVS_BADROOT commits as root fail' |
| 12 | test_done |
| 13 | fi |
| 14 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 15 | test_expect_success PERL 'setup cvsroot environment' ' |
| 16 | CVSROOT=$(pwd)/cvsroot && |
| 17 | export CVSROOT |
| 18 | ' |
Jeff King | 1b19ccd | 2009-04-03 15:33:59 -0400 | [diff] [blame] | 19 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 20 | test_expect_success PERL 'setup cvsroot' '$CVS init' |
Frank Lichtenheld | 40ae887 | 2008-03-26 17:34:20 +0000 | [diff] [blame] | 21 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 22 | test_expect_success PERL 'setup a cvs module' ' |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 23 | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 24 | mkdir "$CVSROOT/module" && |
Michael Haggerty | 161261b | 2009-02-23 06:08:11 +0100 | [diff] [blame] | 25 | $CVS co -d module-cvs module && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 26 | (cd module-cvs && |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 27 | cat <<EOF >o_fortuna && |
| 28 | O Fortuna |
| 29 | velut luna |
| 30 | statu variabilis, |
| 31 | |
| 32 | semper crescis |
| 33 | aut decrescis; |
| 34 | vita detestabilis |
| 35 | |
| 36 | nunc obdurat |
| 37 | et tunc curat |
| 38 | ludo mentis aciem, |
| 39 | |
| 40 | egestatem, |
| 41 | potestatem |
| 42 | dissolvit ut glaciem. |
| 43 | EOF |
Michael Haggerty | 161261b | 2009-02-23 06:08:11 +0100 | [diff] [blame] | 44 | $CVS add o_fortuna && |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 45 | cat <<EOF >message && |
| 46 | add "O Fortuna" lyrics |
| 47 | |
| 48 | These public domain lyrics make an excellent sample text. |
| 49 | EOF |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 50 | $CVS commit -F message |
| 51 | ) |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 52 | ' |
| 53 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 54 | test_expect_success PERL 'import a trivial module' ' |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 55 | |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 56 | git cvsimport -a -R -z 0 -C module-git module && |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 57 | test_cmp module-cvs/o_fortuna module-git/o_fortuna |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 58 | |
| 59 | ' |
| 60 | |
Junio C Hamano | 347c47e | 2010-09-06 16:46:36 -0700 | [diff] [blame] | 61 | test_expect_success PERL 'pack refs' '(cd module-git && git gc)' |
Jeff King | 9da0dab | 2007-11-28 13:56:11 -0500 | [diff] [blame] | 62 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 63 | test_expect_success PERL 'initial import has correct .git/cvs-revisions' ' |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 64 | |
| 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ð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 70 | test_expect_success PERL 'update cvs module' ' |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 71 | (cd module-cvs && |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 72 | cat <<EOF >o_fortuna && |
| 73 | O Fortune, |
| 74 | like the moon |
| 75 | you are changeable, |
| 76 | |
| 77 | ever waxing |
| 78 | and waning; |
| 79 | hateful life |
| 80 | |
| 81 | first oppresses |
| 82 | and then soothes |
| 83 | as fancy takes it; |
| 84 | |
| 85 | poverty |
| 86 | and power |
| 87 | it melts them like ice. |
| 88 | EOF |
| 89 | cat <<EOF >message && |
| 90 | translate to English |
| 91 | |
| 92 | My Latin is terrible. |
| 93 | EOF |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 94 | $CVS commit -F message |
| 95 | ) |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 96 | ' |
| 97 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 98 | test_expect_success PERL 'update git module' ' |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 99 | |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 100 | (cd module-git && |
Michael J Gruber | 60d5985 | 2010-12-29 22:55:34 +0100 | [diff] [blame] | 101 | git config cvsimport.trackRevisions true && |
| 102 | git cvsimport -a -z 0 module && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 103 | git merge origin |
| 104 | ) && |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 105 | test_cmp module-cvs/o_fortuna module-git/o_fortuna |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 106 | |
| 107 | ' |
| 108 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 109 | test_expect_success PERL 'update has correct .git/cvs-revisions' ' |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 110 | |
| 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ð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 117 | test_expect_success PERL 'update cvs module' ' |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 118 | |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 119 | (cd module-cvs && |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 120 | echo 1 >tick && |
Michael Haggerty | 161261b | 2009-02-23 06:08:11 +0100 | [diff] [blame] | 121 | $CVS add tick && |
| 122 | $CVS commit -m 1 |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 123 | ) |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 124 | ' |
| 125 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 126 | test_expect_success PERL 'cvsimport.module config works' ' |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 127 | |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 128 | (cd module-git && |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 129 | git config cvsimport.module module && |
Michael J Gruber | 60d5985 | 2010-12-29 22:55:34 +0100 | [diff] [blame] | 130 | git config cvsimport.trackRevisions true && |
| 131 | git cvsimport -a -z0 && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 132 | git merge origin |
| 133 | ) && |
Junio C Hamano | 3af8286 | 2008-05-23 22:28:56 -0700 | [diff] [blame] | 134 | test_cmp module-cvs/tick module-git/tick |
Jeff King | 67d2324 | 2007-11-30 17:22:12 -0500 | [diff] [blame] | 135 | |
| 136 | ' |
| 137 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 138 | test_expect_success PERL 'second update has correct .git/cvs-revisions' ' |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 139 | |
| 140 | (cd module-git && |
| 141 | git log --format="o_fortuna 1.1 %H" -1 HEAD^^ && |
Eric Sunshine | cff4243 | 2018-07-01 20:24:04 -0400 | [diff] [blame] | 142 | git log --format="o_fortuna 1.2 %H" -1 HEAD^ && |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 143 | git log --format="tick 1.1 %H" -1 HEAD) > expected && |
| 144 | test_cmp expected module-git/.git/cvs-revisions |
| 145 | ' |
| 146 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 147 | test_expect_success PERL 'import from a CVS working tree' ' |
Jeff King | 4e596e9 | 2007-12-02 12:22:19 -0500 | [diff] [blame] | 148 | |
Michael Haggerty | 161261b | 2009-02-23 06:08:11 +0100 | [diff] [blame] | 149 | $CVS co -d import-from-wt module && |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 150 | (cd import-from-wt && |
Michael J Gruber | 60d5985 | 2010-12-29 22:55:34 +0100 | [diff] [blame] | 151 | git config cvsimport.trackRevisions false && |
Jeff King | 4e596e9 | 2007-12-02 12:22:19 -0500 | [diff] [blame] | 152 | git cvsimport -a -z0 && |
| 153 | echo 1 >expect && |
| 154 | git log -1 --pretty=format:%s%n >actual && |
Matthew DeVore | dcbaa0b | 2018-10-05 14:54:04 -0700 | [diff] [blame] | 155 | test_cmp expect actual |
Jens Lehmann | fd4ec4f | 2010-09-06 20:39:54 +0200 | [diff] [blame] | 156 | ) |
Jeff King | 4e596e9 | 2007-12-02 12:22:19 -0500 | [diff] [blame] | 157 | |
| 158 | ' |
| 159 | |
Ævar Arnfjörð Bjarmason | 900eab4 | 2010-08-13 20:40:07 +0000 | [diff] [blame] | 160 | test_expect_success PERL 'no .git/cvs-revisions created by default' ' |
Aaron Crane | 0455ec0 | 2010-02-06 18:26:24 +0000 | [diff] [blame] | 161 | |
| 162 | ! test -e import-from-wt/.git/cvs-revisions |
| 163 | |
| 164 | ' |
| 165 | |
Johannes Schindelin | 765577b | 2020-11-18 23:44:43 +0000 | [diff] [blame] | 166 | test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree main' |
Michael Haggerty | cefa318 | 2009-02-23 06:08:12 +0100 | [diff] [blame] | 167 | |
Jeff King | 795c7c0 | 2007-11-28 13:55:46 -0500 | [diff] [blame] | 168 | test_done |