t / t9301-fast-export.shon commit Merge branch 'np/no-loosen-prune-expire-now' (0854156)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Johannes E. Schindelin
   4#
   5
   6test_description='git fast-export'
   7. ./test-lib.sh
   8
   9test_expect_success 'setup' '
  10
  11        echo Wohlauf > file &&
  12        git add file &&
  13        test_tick &&
  14        git commit -m initial &&
  15        echo die Luft > file &&
  16        echo geht frisch > file2 &&
  17        git add file file2 &&
  18        test_tick &&
  19        git commit -m second &&
  20        echo und > file2 &&
  21        test_tick &&
  22        git commit -m third file2 &&
  23        test_tick &&
  24        git tag rein &&
  25        git checkout -b wer HEAD^ &&
  26        echo lange > file2
  27        test_tick &&
  28        git commit -m sitzt file2 &&
  29        test_tick &&
  30        git tag -a -m valentin muss &&
  31        git merge -s ours master
  32
  33'
  34
  35test_expect_success 'fast-export | fast-import' '
  36
  37        MASTER=$(git rev-parse --verify master) &&
  38        REIN=$(git rev-parse --verify rein) &&
  39        WER=$(git rev-parse --verify wer) &&
  40        MUSS=$(git rev-parse --verify muss) &&
  41        mkdir new &&
  42        git --git-dir=new/.git init &&
  43        git fast-export --all |
  44        (cd new &&
  45         git fast-import &&
  46         test $MASTER = $(git rev-parse --verify refs/heads/master) &&
  47         test $REIN = $(git rev-parse --verify refs/tags/rein) &&
  48         test $WER = $(git rev-parse --verify refs/heads/wer) &&
  49         test $MUSS = $(git rev-parse --verify refs/tags/muss))
  50
  51'
  52
  53test_expect_success 'fast-export master~2..master' '
  54
  55        git fast-export master~2..master |
  56                sed "s/master/partial/" |
  57                (cd new &&
  58                 git fast-import &&
  59                 test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
  60                 git diff master..partial &&
  61                 git diff master^..partial^ &&
  62                 test_must_fail git rev-parse partial~2)
  63
  64'
  65
  66test_expect_success 'iso-8859-1' '
  67
  68        git config i18n.commitencoding ISO-8859-1 &&
  69        # use author and committer name in ISO-8859-1 to match it.
  70        . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
  71        test_tick &&
  72        echo rosten >file &&
  73        git commit -s -m den file &&
  74        git fast-export wer^..wer |
  75                sed "s/wer/i18n/" |
  76                (cd new &&
  77                 git fast-import &&
  78                 git cat-file commit i18n | grep "Áéí óú")
  79
  80'
  81test_expect_success 'import/export-marks' '
  82
  83        git checkout -b marks master &&
  84        git fast-export --export-marks=tmp-marks HEAD &&
  85        test -s tmp-marks &&
  86        test $(wc -l < tmp-marks) -eq 3 &&
  87        test $(
  88                git fast-export --import-marks=tmp-marks\
  89                --export-marks=tmp-marks HEAD |
  90                grep ^commit |
  91                wc -l) \
  92        -eq 0 &&
  93        echo change > file &&
  94        git commit -m "last commit" file &&
  95        test $(
  96                git fast-export --import-marks=tmp-marks \
  97                --export-marks=tmp-marks HEAD |
  98                grep ^commit\  |
  99                wc -l) \
 100        -eq 1 &&
 101        test $(wc -l < tmp-marks) -eq 4
 102
 103'
 104
 105cat > signed-tag-import << EOF
 106tag sign-your-name
 107from $(git rev-parse HEAD)
 108tagger C O Mitter <committer@example.com> 1112911993 -0700
 109data 210
 110A message for a sign
 111-----BEGIN PGP SIGNATURE-----
 112Version: GnuPG v1.4.5 (GNU/Linux)
 113
 114fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
 115aturefakedsignaturefake=
 116=/59v
 117-----END PGP SIGNATURE-----
 118EOF
 119
 120test_expect_success 'set up faked signed tag' '
 121
 122        cat signed-tag-import | git fast-import
 123
 124'
 125
 126test_expect_success 'signed-tags=abort' '
 127
 128        test_must_fail git fast-export --signed-tags=abort sign-your-name
 129
 130'
 131
 132test_expect_success 'signed-tags=verbatim' '
 133
 134        git fast-export --signed-tags=verbatim sign-your-name > output &&
 135        grep PGP output
 136
 137'
 138
 139test_expect_success 'signed-tags=strip' '
 140
 141        git fast-export --signed-tags=strip sign-your-name > output &&
 142        ! grep PGP output
 143
 144'
 145
 146test_expect_success 'setup submodule' '
 147
 148        git checkout -f master &&
 149        mkdir sub &&
 150        cd sub &&
 151        git init  &&
 152        echo test file > file &&
 153        git add file &&
 154        git commit -m sub_initial &&
 155        cd .. &&
 156        git submodule add "`pwd`/sub" sub &&
 157        git commit -m initial &&
 158        test_tick &&
 159        cd sub &&
 160        echo more data >> file &&
 161        git add file &&
 162        git commit -m sub_second &&
 163        cd .. &&
 164        git add sub &&
 165        git commit -m second
 166
 167'
 168
 169test_expect_success 'submodule fast-export | fast-import' '
 170
 171        SUBENT1=$(git ls-tree master^ sub) &&
 172        SUBENT2=$(git ls-tree master sub) &&
 173        rm -rf new &&
 174        mkdir new &&
 175        git --git-dir=new/.git init &&
 176        git fast-export --signed-tags=strip --all |
 177        (cd new &&
 178         git fast-import &&
 179         test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
 180         test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" &&
 181         git checkout master &&
 182         git submodule init &&
 183         git submodule update &&
 184         cmp sub/file ../sub/file)
 185
 186'
 187
 188export GIT_AUTHOR_NAME='A U Thor'
 189export GIT_COMMITTER_NAME='C O Mitter'
 190
 191test_expect_success 'setup copies' '
 192
 193        git config --unset i18n.commitencoding &&
 194        git checkout -b copy rein &&
 195        git mv file file3 &&
 196        git commit -m move1 &&
 197        test_tick &&
 198        cp file2 file4 &&
 199        git add file4 &&
 200        git mv file2 file5 &&
 201        git commit -m copy1 &&
 202        test_tick &&
 203        cp file3 file6 &&
 204        git add file6 &&
 205        git commit -m copy2 &&
 206        test_tick &&
 207        echo more text >> file6 &&
 208        echo even more text >> file6 &&
 209        git add file6 &&
 210        git commit -m modify &&
 211        test_tick &&
 212        cp file6 file7 &&
 213        echo test >> file7 &&
 214        git add file7 &&
 215        git commit -m copy_modify
 216
 217'
 218
 219test_expect_success 'fast-export -C -C | fast-import' '
 220
 221        ENTRY=$(git rev-parse --verify copy) &&
 222        rm -rf new &&
 223        mkdir new &&
 224        git --git-dir=new/.git init &&
 225        git fast-export -C -C --signed-tags=strip --all > output &&
 226        grep "^C \"file6\" \"file7\"\$" output &&
 227        cat output |
 228        (cd new &&
 229         git fast-import &&
 230         test $ENTRY = $(git rev-parse --verify refs/heads/copy))
 231
 232'
 233
 234test_expect_success 'fast-export | fast-import when master is tagged' '
 235
 236        git tag -m msg last &&
 237        git fast-export -C -C --signed-tags=strip --all > output &&
 238        test $(grep -c "^tag " output) = 3
 239
 240'
 241
 242cat > tag-content << EOF
 243object $(git rev-parse HEAD)
 244type commit
 245tag rosten
 246EOF
 247
 248test_expect_success 'cope with tagger-less tags' '
 249
 250        TAG=$(git hash-object -t tag -w tag-content) &&
 251        git update-ref refs/tags/sonnenschein $TAG &&
 252        git fast-export -C -C --signed-tags=strip --all > output &&
 253        test $(grep -c "^tag " output) = 4 &&
 254        ! grep "Unspecified Tagger" output &&
 255        git fast-export -C -C --signed-tags=strip --all \
 256                --fake-missing-tagger > output &&
 257        test $(grep -c "^tag " output) = 4 &&
 258        grep "Unspecified Tagger" output
 259
 260'
 261
 262test_done