| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git cvsimport basic tests' |
| 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
| 7 | . ./lib-cvs.sh |
| 8 | |
| 9 | if ! test_have_prereq NOT_ROOT; then |
| 10 | skip_all='When cvs is compiled with CVS_BADROOT commits as root fail' |
| 11 | test_done |
| 12 | fi |
| 13 | |
| 14 | test_expect_success PERL 'setup cvsroot environment' ' |
| 15 | CVSROOT=$(pwd)/cvsroot && |
| 16 | export CVSROOT |
| 17 | ' |
| 18 | |
| 19 | test_expect_success PERL 'setup cvsroot' '$CVS init' |
| 20 | |
| 21 | test_expect_success PERL 'setup a cvs module' ' |
| 22 | |
| 23 | mkdir "$CVSROOT/module" && |
| 24 | $CVS co -d module-cvs module && |
| 25 | (cd module-cvs && |
| 26 | cat <<EOF >o_fortuna && |
| 27 | O Fortuna |
| 28 | velut luna |
| 29 | statu variabilis, |
| 30 | |
| 31 | semper crescis |
| 32 | aut decrescis; |
| 33 | vita detestabilis |
| 34 | |
| 35 | nunc obdurat |
| 36 | et tunc curat |
| 37 | ludo mentis aciem, |
| 38 | |
| 39 | egestatem, |
| 40 | potestatem |
| 41 | dissolvit ut glaciem. |
| 42 | EOF |
| 43 | $CVS add o_fortuna && |
| 44 | cat <<EOF >message && |
| 45 | add "O Fortuna" lyrics |
| 46 | |
| 47 | These public domain lyrics make an excellent sample text. |
| 48 | EOF |
| 49 | $CVS commit -F message |
| 50 | ) |
| 51 | ' |
| 52 | |
| 53 | test_expect_success PERL 'import a trivial module' ' |
| 54 | |
| 55 | git cvsimport -a -R -z 0 -C module-git module && |
| 56 | test_cmp module-cvs/o_fortuna module-git/o_fortuna |
| 57 | |
| 58 | ' |
| 59 | |
| 60 | test_expect_success PERL 'pack refs' '(cd module-git && git gc)' |
| 61 | |
| 62 | test_expect_success PERL 'initial import has correct .git/cvs-revisions' ' |
| 63 | |
| 64 | (cd module-git && |
| 65 | git log --format="o_fortuna 1.1 %H" -1) > expected && |
| 66 | test_cmp expected module-git/.git/cvs-revisions |
| 67 | ' |
| 68 | |
| 69 | test_expect_success PERL 'update cvs module' ' |
| 70 | (cd module-cvs && |
| 71 | cat <<EOF >o_fortuna && |
| 72 | O Fortune, |
| 73 | like the moon |
| 74 | you are changeable, |
| 75 | |
| 76 | ever waxing |
| 77 | and waning; |
| 78 | hateful life |
| 79 | |
| 80 | first oppresses |
| 81 | and then soothes |
| 82 | as fancy takes it; |
| 83 | |
| 84 | poverty |
| 85 | and power |
| 86 | it melts them like ice. |
| 87 | EOF |
| 88 | cat <<EOF >message && |
| 89 | translate to English |
| 90 | |
| 91 | My Latin is terrible. |
| 92 | EOF |
| 93 | $CVS commit -F message |
| 94 | ) |
| 95 | ' |
| 96 | |
| 97 | test_expect_success PERL 'update git module' ' |
| 98 | |
| 99 | (cd module-git && |
| 100 | git config cvsimport.trackRevisions true && |
| 101 | git cvsimport -a -z 0 module && |
| 102 | git merge origin |
| 103 | ) && |
| 104 | test_cmp module-cvs/o_fortuna module-git/o_fortuna |
| 105 | |
| 106 | ' |
| 107 | |
| 108 | test_expect_success PERL 'update has correct .git/cvs-revisions' ' |
| 109 | |
| 110 | (cd module-git && |
| 111 | git log --format="o_fortuna 1.1 %H" -1 HEAD^ && |
| 112 | git log --format="o_fortuna 1.2 %H" -1 HEAD) > expected && |
| 113 | test_cmp expected module-git/.git/cvs-revisions |
| 114 | ' |
| 115 | |
| 116 | test_expect_success PERL 'update cvs module' ' |
| 117 | |
| 118 | (cd module-cvs && |
| 119 | echo 1 >tick && |
| 120 | $CVS add tick && |
| 121 | $CVS commit -m 1 |
| 122 | ) |
| 123 | ' |
| 124 | |
| 125 | test_expect_success PERL 'cvsimport.module config works' ' |
| 126 | |
| 127 | (cd module-git && |
| 128 | git config cvsimport.module module && |
| 129 | git config cvsimport.trackRevisions true && |
| 130 | git cvsimport -a -z0 && |
| 131 | git merge origin |
| 132 | ) && |
| 133 | test_cmp module-cvs/tick module-git/tick |
| 134 | |
| 135 | ' |
| 136 | |
| 137 | test_expect_success PERL 'second update has correct .git/cvs-revisions' ' |
| 138 | |
| 139 | (cd module-git && |
| 140 | git log --format="o_fortuna 1.1 %H" -1 HEAD^^ && |
| 141 | git log --format="o_fortuna 1.2 %H" -1 HEAD^ && |
| 142 | git log --format="tick 1.1 %H" -1 HEAD) > expected && |
| 143 | test_cmp expected module-git/.git/cvs-revisions |
| 144 | ' |
| 145 | |
| 146 | test_expect_success PERL 'import from a CVS working tree' ' |
| 147 | |
| 148 | $CVS co -d import-from-wt module && |
| 149 | (cd import-from-wt && |
| 150 | git config cvsimport.trackRevisions false && |
| 151 | git cvsimport -a -z0 && |
| 152 | echo 1 >expect && |
| 153 | git log -1 --pretty=format:%s%n >actual && |
| 154 | test_cmp expect actual |
| 155 | ) |
| 156 | |
| 157 | ' |
| 158 | |
| 159 | test_expect_success PERL 'no .git/cvs-revisions created by default' ' |
| 160 | |
| 161 | ! test -e import-from-wt/.git/cvs-revisions |
| 162 | |
| 163 | ' |
| 164 | |
| 165 | test_expect_success PERL 'test entire HEAD' 'test_cmp_branch_tree main' |
| 166 | |
| 167 | test_done |