t / t9301-fast-export.shon commit Merge branch 'lt/maint-gitdir-relative' (8bcff62)
   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                 ! 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        . ../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        cp tmp-marks ~ &&
  87        test $(wc -l < tmp-marks) -eq 3 &&
  88        test $(
  89                git fast-export --import-marks=tmp-marks\
  90                --export-marks=tmp-marks HEAD |
  91                grep ^commit |
  92                wc -l) \
  93        -eq 0 &&
  94        echo change > file &&
  95        git commit -m "last commit" file &&
  96        test $(
  97                git fast-export --import-marks=tmp-marks \
  98                --export-marks=tmp-marks HEAD |
  99                grep ^commit\  |
 100                wc -l) \
 101        -eq 1 &&
 102        test $(wc -l < tmp-marks) -eq 4
 103
 104'
 105
 106cat > signed-tag-import << EOF
 107tag sign-your-name
 108from $(git rev-parse HEAD)
 109tagger C O Mitter <committer@example.com> 1112911993 -0700
 110data 210
 111A message for a sign
 112-----BEGIN PGP SIGNATURE-----
 113Version: GnuPG v1.4.5 (GNU/Linux)
 114
 115fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
 116aturefakedsignaturefake=
 117=/59v
 118-----END PGP SIGNATURE-----
 119EOF
 120
 121test_expect_success 'set up faked signed tag' '
 122
 123        cat signed-tag-import | git fast-import
 124
 125'
 126
 127test_expect_success 'signed-tags=abort' '
 128
 129        ! git fast-export --signed-tags=abort sign-your-name
 130
 131'
 132
 133test_expect_success 'signed-tags=verbatim' '
 134
 135        git fast-export --signed-tags=verbatim sign-your-name > output &&
 136        grep PGP output
 137
 138'
 139
 140test_expect_success 'signed-tags=strip' '
 141
 142        git fast-export --signed-tags=strip sign-your-name > output &&
 143        ! grep PGP output
 144
 145'
 146
 147test_done