3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git fast-export'
9 test_expect_success
'setup' '
11 echo break it > file0 &&
14 echo Wohlauf > file &&
17 git commit -m initial &&
18 echo die Luft > file &&
19 echo geht frisch > file2 &&
22 git commit -m second &&
25 git commit -m third file2 &&
28 git checkout -b wer HEAD^ &&
31 git commit -m sitzt file2 &&
33 git tag -a -m valentin muss &&
34 git merge -s ours master
38 test_expect_success
'fast-export | fast-import' '
40 MASTER=$(git rev-parse --verify master) &&
41 REIN=$(git rev-parse --verify rein) &&
42 WER=$(git rev-parse --verify wer) &&
43 MUSS=$(git rev-parse --verify muss) &&
45 git --git-dir=new/.git init &&
46 git fast-export --all |
49 test $MASTER = $(git rev-parse --verify refs/heads/master) &&
50 test $REIN = $(git rev-parse --verify refs/tags/rein) &&
51 test $WER = $(git rev-parse --verify refs/heads/wer) &&
52 test $MUSS = $(git rev-parse --verify refs/tags/muss))
56 test_expect_success
'fast-export master~2..master' '
58 git fast-export master~2..master |
59 sed "s/master/partial/" |
62 test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
63 git diff --exit-code master partial &&
64 git diff --exit-code master^ partial^ &&
65 test_must_fail git rev-parse partial~2)
69 test_expect_success
'iso-8859-1' '
71 git config i18n.commitencoding ISO8859-1 &&
72 # use author and committer name in ISO-8859-1 to match it.
73 . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
76 git commit -s -m den file &&
77 git fast-export wer^..wer |
81 git cat-file commit i18n | grep "Áéí óú")
84 test_expect_success
'import/export-marks' '
86 git checkout -b marks master &&
87 git fast-export --export-marks=tmp-marks HEAD &&
89 test $(wc -l < tmp-marks) -eq 3 &&
91 git fast-export --import-marks=tmp-marks\
92 --export-marks=tmp-marks HEAD |
97 git commit -m "last commit" file &&
99 git fast-export --import-marks=tmp-marks \
100 --export-marks=tmp-marks HEAD |
104 test $(wc -l < tmp-marks) -eq 4
108 cat > signed-tag-import
<< EOF
110 from $(git rev-parse HEAD)
111 tagger C O Mitter <committer@example.com> 1112911993 -0700
114 -----BEGIN PGP SIGNATURE-----
115 Version: GnuPG v1.4.5 (GNU/Linux)
117 fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
118 aturefakedsignaturefake=
120 -----END PGP SIGNATURE-----
123 test_expect_success
'set up faked signed tag' '
125 cat signed-tag-import | git fast-import
129 test_expect_success
'signed-tags=abort' '
131 test_must_fail git fast-export --signed-tags=abort sign-your-name
135 test_expect_success
'signed-tags=verbatim' '
137 git fast-export --signed-tags=verbatim sign-your-name > output &&
142 test_expect_success
'signed-tags=strip' '
144 git fast-export --signed-tags=strip sign-your-name > output &&
149 test_expect_success
'setup submodule' '
151 git checkout -f master &&
155 echo test file > file &&
157 git commit -m sub_initial &&
159 git submodule add "`pwd`/sub" sub &&
160 git commit -m initial &&
163 echo more data >> file &&
165 git commit -m sub_second &&
172 test_expect_success
'submodule fast-export | fast-import' '
174 SUBENT1=$(git ls-tree master^ sub) &&
175 SUBENT2=$(git ls-tree master sub) &&
178 git --git-dir=new/.git init &&
179 git fast-export --signed-tags=strip --all |
182 test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
183 test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" &&
184 git checkout master &&
185 git submodule init &&
186 git submodule update &&
187 cmp sub/file ../sub/file)
191 GIT_AUTHOR_NAME
='A U Thor'; export GIT_AUTHOR_NAME
192 GIT_COMMITTER_NAME
='C O Mitter'; export GIT_COMMITTER_NAME
194 test_expect_success
'setup copies' '
196 git config --unset i18n.commitencoding &&
197 git checkout -b copy rein &&
199 git commit -m move1 &&
203 git mv file2 file5 &&
204 git commit -m copy1 &&
208 git commit -m copy2 &&
210 echo more text >> file6 &&
211 echo even more text >> file6 &&
213 git commit -m modify &&
216 echo test >> file7 &&
218 git commit -m copy_modify
222 test_expect_success
'fast-export -C -C | fast-import' '
224 ENTRY=$(git rev-parse --verify copy) &&
227 git --git-dir=new/.git init &&
228 git fast-export -C -C --signed-tags=strip --all > output &&
229 grep "^C \"file6\" \"file7\"\$" output &&
233 test $ENTRY = $(git rev-parse --verify refs/heads/copy))
237 test_expect_success
'fast-export | fast-import when master is tagged' '
239 git tag -m msg last &&
240 git fast-export -C -C --signed-tags=strip --all > output &&
241 test $(grep -c "^tag " output) = 3
245 cat > tag-content
<< EOF
246 object $(git rev-parse HEAD)
251 test_expect_success
'cope with tagger-less tags' '
253 TAG=$(git hash-object -t tag -w tag-content) &&
254 git update-ref refs/tags/sonnenschein $TAG &&
255 git fast-export -C -C --signed-tags=strip --all > output &&
256 test $(grep -c "^tag " output) = 4 &&
257 ! grep "Unspecified Tagger" output &&
258 git fast-export -C -C --signed-tags=strip --all \
259 --fake-missing-tagger > output &&
260 test $(grep -c "^tag " output) = 4 &&
261 grep "Unspecified Tagger" output
265 test_expect_success
'setup for limiting exports by PATH' '
266 mkdir limit-by-paths &&
271 git commit -m "First file" &&
274 git commit -m "Second file" &&
275 git tag -a -m msg mytag &&
276 echo morefoo >> bar &&
278 git commit -m "Change to second file" &&
282 cat > limit-by-paths
/expected
<< EOF
288 reset refs/tags/mytag
289 commit refs/tags/mytag
291 author A U Thor <author@example.com> 1112912713 -0700
292 committer C O Mitter <committer@example.com> 1112912713 -0700
299 test_expect_success
'dropping tag of filtered out object' '
301 git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
302 test_cmp output expected &&
306 cat >> limit-by-paths
/expected
<< EOF
309 tagger C O Mitter <committer@example.com> 1112912713 -0700
315 test_expect_success
'rewriting tag of filtered out object' '
317 git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
318 test_cmp output expected &&
322 cat > limit-by-paths
/expected
<< EOF
333 reset refs/heads/master
334 commit refs/heads/master
336 author A U Thor <author@example.com> 1112912713 -0700
337 committer C O Mitter <committer@example.com> 1112912713 -0700
345 test_expect_failure
'no exact-ref revisions included' '
347 git fast-export master~2..master~1 > output &&
348 test_cmp output expected &&
353 test_expect_success
'set-up a few more tags for tag export tests' '
354 git checkout -f master &&
355 HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
356 git tag tree_tag -m "tagging a tree" $HEAD_TREE &&
357 git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE &&
358 git tag tag-obj_tag -m "tagging a tag" tree_tag-obj &&
359 git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj
362 test_expect_success
'tree_tag' '
364 (cd result && git init) &&
365 git fast-export tree_tag > fe-stream &&
366 (cd result && git fast-import < ../fe-stream)
369 # NEEDSWORK: not just check return status, but validate the output
370 test_expect_success
'tree_tag-obj' 'git fast-export tree_tag-obj'
371 test_expect_success
'tag-obj_tag' 'git fast-export tag-obj_tag'
372 test_expect_success
'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'