2007-12-02 15:14:13 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
2008-09-09 23:25:25 +02:00
|
|
|
test_description='git fast-export'
|
2007-12-02 15:14:13 +01:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
|
2009-03-26 00:53:23 +01:00
|
|
|
echo break it > file0 &&
|
|
|
|
git add file0 &&
|
|
|
|
test_tick &&
|
2007-12-02 15:14:13 +01:00
|
|
|
echo Wohlauf > file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
echo die Luft > file &&
|
|
|
|
echo geht frisch > file2 &&
|
|
|
|
git add file file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m second &&
|
|
|
|
echo und > file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m third file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git tag rein &&
|
|
|
|
git checkout -b wer HEAD^ &&
|
|
|
|
echo lange > file2
|
|
|
|
test_tick &&
|
|
|
|
git commit -m sitzt file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git tag -a -m valentin muss &&
|
|
|
|
git merge -s ours master
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export | fast-import' '
|
|
|
|
|
|
|
|
MASTER=$(git rev-parse --verify master) &&
|
|
|
|
REIN=$(git rev-parse --verify rein) &&
|
|
|
|
WER=$(git rev-parse --verify wer) &&
|
|
|
|
MUSS=$(git rev-parse --verify muss) &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export --all |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $MASTER = $(git rev-parse --verify refs/heads/master) &&
|
|
|
|
test $REIN = $(git rev-parse --verify refs/tags/rein) &&
|
|
|
|
test $WER = $(git rev-parse --verify refs/heads/wer) &&
|
|
|
|
test $MUSS = $(git rev-parse --verify refs/tags/muss))
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export master~2..master' '
|
|
|
|
|
|
|
|
git fast-export master~2..master |
|
|
|
|
sed "s/master/partial/" |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
|
2009-03-26 00:53:23 +01:00
|
|
|
git diff --exit-code master partial &&
|
|
|
|
git diff --exit-code master^ partial^ &&
|
2008-07-12 17:47:52 +02:00
|
|
|
test_must_fail git rev-parse partial~2)
|
2007-12-02 15:14:13 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'iso-8859-1' '
|
|
|
|
|
|
|
|
git config i18n.commitencoding ISO-8859-1 &&
|
|
|
|
# use author and committer name in ISO-8859-1 to match it.
|
2008-08-08 11:26:28 +02:00
|
|
|
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
|
2007-12-02 15:14:13 +01:00
|
|
|
test_tick &&
|
|
|
|
echo rosten >file &&
|
|
|
|
git commit -s -m den file &&
|
|
|
|
git fast-export wer^..wer |
|
|
|
|
sed "s/wer/i18n/" |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
git cat-file commit i18n | grep "Áéí óú")
|
|
|
|
|
2008-06-11 13:17:04 +02:00
|
|
|
'
|
|
|
|
test_expect_success 'import/export-marks' '
|
|
|
|
|
|
|
|
git checkout -b marks master &&
|
|
|
|
git fast-export --export-marks=tmp-marks HEAD &&
|
|
|
|
test -s tmp-marks &&
|
|
|
|
test $(wc -l < tmp-marks) -eq 3 &&
|
|
|
|
test $(
|
|
|
|
git fast-export --import-marks=tmp-marks\
|
|
|
|
--export-marks=tmp-marks HEAD |
|
|
|
|
grep ^commit |
|
|
|
|
wc -l) \
|
|
|
|
-eq 0 &&
|
|
|
|
echo change > file &&
|
|
|
|
git commit -m "last commit" file &&
|
|
|
|
test $(
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks HEAD |
|
|
|
|
grep ^commit\ |
|
|
|
|
wc -l) \
|
|
|
|
-eq 1 &&
|
|
|
|
test $(wc -l < tmp-marks) -eq 4
|
|
|
|
|
2007-12-02 15:14:13 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
cat > signed-tag-import << EOF
|
|
|
|
tag sign-your-name
|
|
|
|
from $(git rev-parse HEAD)
|
|
|
|
tagger C O Mitter <committer@example.com> 1112911993 -0700
|
|
|
|
data 210
|
|
|
|
A message for a sign
|
|
|
|
-----BEGIN PGP SIGNATURE-----
|
|
|
|
Version: GnuPG v1.4.5 (GNU/Linux)
|
|
|
|
|
|
|
|
fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
|
|
|
|
aturefakedsignaturefake=
|
|
|
|
=/59v
|
|
|
|
-----END PGP SIGNATURE-----
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'set up faked signed tag' '
|
|
|
|
|
|
|
|
cat signed-tag-import | git fast-import
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'signed-tags=abort' '
|
|
|
|
|
2008-07-12 17:47:52 +02:00
|
|
|
test_must_fail git fast-export --signed-tags=abort sign-your-name
|
2007-12-02 15:14:13 +01:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-03 23:44:39 +01:00
|
|
|
test_expect_success 'signed-tags=verbatim' '
|
2007-12-02 15:14:13 +01:00
|
|
|
|
2007-12-03 23:44:39 +01:00
|
|
|
git fast-export --signed-tags=verbatim sign-your-name > output &&
|
2007-12-02 15:14:13 +01:00
|
|
|
grep PGP output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'signed-tags=strip' '
|
|
|
|
|
|
|
|
git fast-export --signed-tags=strip sign-your-name > output &&
|
|
|
|
! grep PGP output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-07-19 14:21:24 +02:00
|
|
|
test_expect_success 'setup submodule' '
|
|
|
|
|
|
|
|
git checkout -f master &&
|
|
|
|
mkdir sub &&
|
|
|
|
cd sub &&
|
|
|
|
git init &&
|
|
|
|
echo test file > file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -m sub_initial &&
|
|
|
|
cd .. &&
|
|
|
|
git submodule add "`pwd`/sub" sub &&
|
|
|
|
git commit -m initial &&
|
|
|
|
test_tick &&
|
|
|
|
cd sub &&
|
|
|
|
echo more data >> file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -m sub_second &&
|
|
|
|
cd .. &&
|
|
|
|
git add sub &&
|
|
|
|
git commit -m second
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule fast-export | fast-import' '
|
|
|
|
|
|
|
|
SUBENT1=$(git ls-tree master^ sub) &&
|
|
|
|
SUBENT2=$(git ls-tree master sub) &&
|
|
|
|
rm -rf new &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export --signed-tags=strip --all |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
|
|
|
|
test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" &&
|
|
|
|
git checkout master &&
|
|
|
|
git submodule init &&
|
|
|
|
git submodule update &&
|
|
|
|
cmp sub/file ../sub/file)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-02-18 20:17:27 +01:00
|
|
|
GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME
|
|
|
|
GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME
|
2008-07-26 22:52:54 +02:00
|
|
|
|
|
|
|
test_expect_success 'setup copies' '
|
|
|
|
|
|
|
|
git config --unset i18n.commitencoding &&
|
|
|
|
git checkout -b copy rein &&
|
|
|
|
git mv file file3 &&
|
|
|
|
git commit -m move1 &&
|
|
|
|
test_tick &&
|
|
|
|
cp file2 file4 &&
|
|
|
|
git add file4 &&
|
|
|
|
git mv file2 file5 &&
|
|
|
|
git commit -m copy1 &&
|
|
|
|
test_tick &&
|
|
|
|
cp file3 file6 &&
|
|
|
|
git add file6 &&
|
|
|
|
git commit -m copy2 &&
|
|
|
|
test_tick &&
|
|
|
|
echo more text >> file6 &&
|
|
|
|
echo even more text >> file6 &&
|
|
|
|
git add file6 &&
|
|
|
|
git commit -m modify &&
|
|
|
|
test_tick &&
|
|
|
|
cp file6 file7 &&
|
|
|
|
echo test >> file7 &&
|
|
|
|
git add file7 &&
|
|
|
|
git commit -m copy_modify
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export -C -C | fast-import' '
|
|
|
|
|
|
|
|
ENTRY=$(git rev-parse --verify copy) &&
|
|
|
|
rm -rf new &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
|
|
|
grep "^C \"file6\" \"file7\"\$" output &&
|
|
|
|
cat output |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $ENTRY = $(git rev-parse --verify refs/heads/copy))
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-11-23 12:55:54 +01:00
|
|
|
test_expect_success 'fast-export | fast-import when master is tagged' '
|
2008-11-22 19:22:48 +01:00
|
|
|
|
|
|
|
git tag -m msg last &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
|
|
|
test $(grep -c "^tag " output) = 3
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-12-20 01:00:27 +01:00
|
|
|
cat > tag-content << EOF
|
|
|
|
object $(git rev-parse HEAD)
|
|
|
|
type commit
|
|
|
|
tag rosten
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'cope with tagger-less tags' '
|
|
|
|
|
|
|
|
TAG=$(git hash-object -t tag -w tag-content) &&
|
|
|
|
git update-ref refs/tags/sonnenschein $TAG &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
|
|
|
test $(grep -c "^tag " output) = 4 &&
|
|
|
|
! grep "Unspecified Tagger" output &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all \
|
|
|
|
--fake-missing-tagger > output &&
|
|
|
|
test $(grep -c "^tag " output) = 4 &&
|
|
|
|
grep "Unspecified Tagger" output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-02 15:14:13 +01:00
|
|
|
test_done
|