3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git fast-export'
9 test_expect_success
'setup' '
11 echo Wohlauf > file &&
14 git commit -m initial &&
15 echo die Luft > file &&
16 echo geht frisch > file2 &&
19 git commit -m second &&
22 git commit -m third file2 &&
25 git checkout -b wer HEAD^ &&
28 git commit -m sitzt file2 &&
30 git tag -a -m valentin muss &&
31 git merge -s ours master
35 test_expect_success
'fast-export | fast-import' '
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) &&
42 git --git-dir=new/.git init &&
43 git fast-export --all |
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))
53 test_expect_success
'fast-export master~2..master' '
55 git fast-export master~2..master |
56 sed "s/master/partial/" |
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)
66 test_expect_success
'iso-8859-1' '
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 &&
73 git commit -s -m den file &&
74 git fast-export wer^..wer |
78 git cat-file commit i18n | grep "Áéí óú")
81 test_expect_success
'import/export-marks' '
83 git checkout -b marks master &&
84 git fast-export --export-marks=tmp-marks HEAD &&
86 test $(wc -l < tmp-marks) -eq 3 &&
88 git fast-export --import-marks=tmp-marks\
89 --export-marks=tmp-marks HEAD |
94 git commit -m "last commit" file &&
96 git fast-export --import-marks=tmp-marks \
97 --export-marks=tmp-marks HEAD |
101 test $(wc -l < tmp-marks) -eq 4
105 cat > signed-tag-import
<< EOF
107 from $(git rev-parse HEAD)
108 tagger C O Mitter <committer@example.com> 1112911993 -0700
111 -----BEGIN PGP SIGNATURE-----
112 Version: GnuPG v1.4.5 (GNU/Linux)
114 fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
115 aturefakedsignaturefake=
117 -----END PGP SIGNATURE-----
120 test_expect_success
'set up faked signed tag' '
122 cat signed-tag-import | git fast-import
126 test_expect_success
'signed-tags=abort' '
128 test_must_fail git fast-export --signed-tags=abort sign-your-name
132 test_expect_success
'signed-tags=verbatim' '
134 git fast-export --signed-tags=verbatim sign-your-name > output &&
139 test_expect_success
'signed-tags=strip' '
141 git fast-export --signed-tags=strip sign-your-name > output &&
146 test_expect_success
'setup submodule' '
148 git checkout -f master &&
152 echo test file > file &&
154 git commit -m sub_initial &&
156 git submodule add "`pwd`/sub" sub &&
157 git commit -m initial &&
160 echo more data >> file &&
162 git commit -m sub_second &&
169 test_expect_success
'submodule fast-export | fast-import' '
171 SUBENT1=$(git ls-tree master^ sub) &&
172 SUBENT2=$(git ls-tree master sub) &&
175 git --git-dir=new/.git init &&
176 git fast-export --signed-tags=strip --all |
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)
188 GIT_AUTHOR_NAME
='A U Thor'; export GIT_AUTHOR_NAME
189 GIT_COMMITTER_NAME
='C O Mitter'; export GIT_COMMITTER_NAME
191 test_expect_success
'setup copies' '
193 git config --unset i18n.commitencoding &&
194 git checkout -b copy rein &&
196 git commit -m move1 &&
200 git mv file2 file5 &&
201 git commit -m copy1 &&
205 git commit -m copy2 &&
207 echo more text >> file6 &&
208 echo even more text >> file6 &&
210 git commit -m modify &&
213 echo test >> file7 &&
215 git commit -m copy_modify
219 test_expect_success
'fast-export -C -C | fast-import' '
221 ENTRY=$(git rev-parse --verify copy) &&
224 git --git-dir=new/.git init &&
225 git fast-export -C -C --signed-tags=strip --all > output &&
226 grep "^C \"file6\" \"file7\"\$" output &&
230 test $ENTRY = $(git rev-parse --verify refs/heads/copy))
234 test_expect_success
'fast-export | fast-import when master is tagged' '
236 git tag -m msg last &&
237 git fast-export -C -C --signed-tags=strip --all > output &&
238 test $(grep -c "^tag " output) = 3
242 cat > tag-content
<< EOF
243 object $(git rev-parse HEAD)
248 test_expect_success
'cope with tagger-less tags' '
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
262 test_expect_success
'set-up a few more tags for tag export tests' '
263 git checkout -f master &&
264 HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
265 git tag tree_tag -m "tagging a tree" $HEAD_TREE &&
266 git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE &&
267 git tag tag-obj_tag -m "tagging a tag" tree_tag-obj &&
268 git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj
271 # NEEDSWORK: not just check return status, but validate the output
272 test_expect_success
'tree_tag' 'git fast-export tree_tag'
273 test_expect_success
'tree_tag-obj' 'git fast-export tree_tag-obj'
274 test_expect_success
'tag-obj_tag' 'git fast-export tag-obj_tag'
275 test_expect_success
'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'