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