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