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