]>
Commit | Line | Data |
---|---|---|
f2dc849e JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Johannes E. Schindelin | |
4 | # | |
5 | ||
eaa2a6fc | 6 | test_description='git fast-export' |
f2dc849e JS |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'setup' ' | |
10 | ||
ebeec7db EN |
11 | echo break it > file0 && |
12 | git add file0 && | |
13 | test_tick && | |
f2dc849e JS |
14 | echo Wohlauf > file && |
15 | git add file && | |
16 | test_tick && | |
17 | git commit -m initial && | |
18 | echo die Luft > file && | |
19 | echo geht frisch > file2 && | |
20 | git add file file2 && | |
21 | test_tick && | |
22 | git commit -m second && | |
23 | echo und > file2 && | |
24 | test_tick && | |
25 | git commit -m third file2 && | |
26 | test_tick && | |
27 | git tag rein && | |
28 | git checkout -b wer HEAD^ && | |
a48fcd83 | 29 | echo lange > file2 && |
f2dc849e JS |
30 | test_tick && |
31 | git commit -m sitzt file2 && | |
32 | test_tick && | |
33 | git tag -a -m valentin muss && | |
34 | git merge -s ours master | |
35 | ||
36 | ' | |
37 | ||
38 | test_expect_success 'fast-export | fast-import' ' | |
39 | ||
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) && | |
44 | mkdir new && | |
45 | git --git-dir=new/.git init && | |
a4d4e32a | 46 | git fast-export --all >actual && |
f2dc849e JS |
47 | (cd new && |
48 | git fast-import && | |
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) && | |
a4d4e32a | 52 | test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual |
f2dc849e JS |
53 | |
54 | ' | |
55 | ||
af2abd87 EN |
56 | test_expect_success 'fast-export ^muss^{commit} muss' ' |
57 | git fast-export --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && | |
58 | cat >expected <<-EOF && | |
59 | tag muss | |
60 | from $(git rev-parse --verify muss^{commit}) | |
61 | $(git cat-file tag muss | grep tagger) | |
62 | data 9 | |
63 | valentin | |
64 | ||
65 | EOF | |
66 | test_cmp expected actual | |
67 | ' | |
68 | ||
a1638cfe EN |
69 | test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' |
70 | git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual && | |
71 | cat >expected <<-EOF && | |
72 | tag muss | |
73 | mark :1 | |
74 | from $(git rev-parse --verify muss^{commit}) | |
75 | $(git cat-file tag muss | grep tagger) | |
76 | data 9 | |
77 | valentin | |
78 | ||
79 | EOF | |
80 | test_cmp expected actual | |
81 | ' | |
82 | ||
f2dc849e JS |
83 | test_expect_success 'fast-export master~2..master' ' |
84 | ||
a4d4e32a PK |
85 | git fast-export master~2..master >actual && |
86 | sed "s/master/partial/" actual | | |
f2dc849e JS |
87 | (cd new && |
88 | git fast-import && | |
89 | test $MASTER != $(git rev-parse --verify refs/heads/partial) && | |
ebeec7db EN |
90 | git diff --exit-code master partial && |
91 | git diff --exit-code master^ partial^ && | |
d492b31c | 92 | test_must_fail git rev-parse partial~2) |
f2dc849e JS |
93 | |
94 | ' | |
95 | ||
530ca19c EN |
96 | test_expect_success 'fast-export --reference-excluded-parents master~2..master' ' |
97 | ||
98 | git fast-export --reference-excluded-parents master~2..master >actual && | |
99 | grep commit.refs/heads/master actual >commit-count && | |
100 | test_line_count = 2 commit-count && | |
101 | sed "s/master/rewrite/" actual | | |
102 | (cd new && | |
103 | git fast-import && | |
104 | test $MASTER = $(git rev-parse --verify refs/heads/rewrite)) | |
105 | ' | |
106 | ||
a965bb31 EN |
107 | test_expect_success 'fast-export --show-original-ids' ' |
108 | ||
109 | git fast-export --show-original-ids master >output && | |
110 | grep ^original-oid output| sed -e s/^original-oid.// | sort >actual && | |
111 | git rev-list --objects master muss >objects-and-names && | |
112 | awk "{print \$1}" objects-and-names | sort >commits-trees-blobs && | |
113 | comm -23 actual commits-trees-blobs >unfound && | |
114 | test_must_be_empty unfound | |
115 | ' | |
116 | ||
117 | test_expect_success 'fast-export --show-original-ids | git fast-import' ' | |
118 | ||
119 | git fast-export --show-original-ids master muss | git fast-import --quiet && | |
120 | test $MASTER = $(git rev-parse --verify refs/heads/master) && | |
121 | test $MUSS = $(git rev-parse --verify refs/tags/muss) | |
122 | ' | |
123 | ||
e80001f8 | 124 | test_expect_success 'reencoding iso-8859-7' ' |
f2dc849e | 125 | |
32615ce7 EN |
126 | test_when_finished "git reset --hard HEAD~1" && |
127 | test_config i18n.commitencoding iso-8859-7 && | |
f2dc849e JS |
128 | test_tick && |
129 | echo rosten >file && | |
32615ce7 | 130 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && |
e80001f8 | 131 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
32615ce7 | 132 | sed "s/wer/i18n/" iso-8859-7.fi | |
f2dc849e JS |
133 | (cd new && |
134 | git fast-import && | |
831279d3 | 135 | # The commit object, if not re-encoded, would be 200 bytes plus hash. |
32615ce7 EN |
136 | # Removing the "encoding iso-8859-7\n" header drops 20 bytes. |
137 | # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7 | |
138 | # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for | |
139 | # the expected size. | |
831279d3 | 140 | test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" && |
32615ce7 | 141 | # ...and for the expected translation of bytes. |
a4d4e32a | 142 | git cat-file commit i18n >actual && |
32615ce7 EN |
143 | grep $(printf "\317\200") actual && |
144 | # Also make sure the commit does not have the "encoding" header | |
145 | ! grep ^encoding actual) | |
df6a7ff7 | 146 | ' |
32615ce7 | 147 | |
e80001f8 EN |
148 | test_expect_success 'aborting on iso-8859-7' ' |
149 | ||
150 | test_when_finished "git reset --hard HEAD~1" && | |
151 | test_config i18n.commitencoding iso-8859-7 && | |
152 | echo rosten >file && | |
153 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && | |
154 | test_must_fail git fast-export --reencode=abort wer^..wer >iso-8859-7.fi | |
155 | ' | |
156 | ||
157 | test_expect_success 'preserving iso-8859-7' ' | |
158 | ||
159 | test_when_finished "git reset --hard HEAD~1" && | |
160 | test_config i18n.commitencoding iso-8859-7 && | |
161 | echo rosten >file && | |
162 | git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && | |
163 | git fast-export --reencode=no wer^..wer >iso-8859-7.fi && | |
164 | sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | | |
165 | (cd new && | |
166 | git fast-import && | |
831279d3 | 167 | # The commit object, if not re-encoded, is 200 bytes plus hash. |
e80001f8 EN |
168 | # Removing the "encoding iso-8859-7\n" header would drops 20 |
169 | # bytes. Re-encoding the Pi character from \xF0 (\360) in | |
170 | # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte. | |
171 | # Check for the expected size... | |
831279d3 | 172 | test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" && |
e80001f8 EN |
173 | # ...as well as the expected byte. |
174 | git cat-file commit i18n-no-recoding >actual && | |
175 | grep $(printf "\360") actual && | |
176 | # Also make sure the commit has the "encoding" header | |
177 | grep ^encoding actual) | |
178 | ' | |
179 | ||
ccbfc96d EN |
180 | test_expect_success 'encoding preserved if reencoding fails' ' |
181 | ||
182 | test_when_finished "git reset --hard HEAD~1" && | |
183 | test_config i18n.commitencoding iso-8859-7 && | |
184 | echo rosten >file && | |
185 | git commit -s -F "$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt" file && | |
e80001f8 | 186 | git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && |
ccbfc96d EN |
187 | sed "s/wer/i18n-invalid/" iso-8859-7.fi | |
188 | (cd new && | |
189 | git fast-import && | |
190 | git cat-file commit i18n-invalid >actual && | |
191 | # Make sure the commit still has the encoding header | |
192 | grep ^encoding actual && | |
193 | # Verify that the commit has the expected size; i.e. | |
194 | # that no bytes were re-encoded to a different encoding. | |
831279d3 | 195 | test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" && |
ccbfc96d EN |
196 | # ...and check for the original special bytes |
197 | grep $(printf "\360") actual && | |
198 | grep $(printf "\377") actual) | |
199 | ' | |
200 | ||
df6a7ff7 PB |
201 | test_expect_success 'import/export-marks' ' |
202 | ||
203 | git checkout -b marks master && | |
204 | git fast-export --export-marks=tmp-marks HEAD && | |
205 | test -s tmp-marks && | |
3fb0459b | 206 | test_line_count = 3 tmp-marks && |
a4d4e32a PK |
207 | git fast-export --import-marks=tmp-marks \ |
208 | --export-marks=tmp-marks HEAD >actual && | |
209 | test $(grep ^commit actual | wc -l) -eq 0 && | |
df6a7ff7 PB |
210 | echo change > file && |
211 | git commit -m "last commit" file && | |
a4d4e32a PK |
212 | git fast-export --import-marks=tmp-marks \ |
213 | --export-marks=tmp-marks HEAD >actual && | |
214 | test $(grep ^commit\ actual | wc -l) -eq 1 && | |
3fb0459b | 215 | test_line_count = 4 tmp-marks |
df6a7ff7 | 216 | |
f2dc849e JS |
217 | ' |
218 | ||
219 | cat > signed-tag-import << EOF | |
220 | tag sign-your-name | |
221 | from $(git rev-parse HEAD) | |
222 | tagger C O Mitter <committer@example.com> 1112911993 -0700 | |
223 | data 210 | |
224 | A message for a sign | |
225 | -----BEGIN PGP SIGNATURE----- | |
226 | Version: GnuPG v1.4.5 (GNU/Linux) | |
227 | ||
228 | fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign | |
229 | aturefakedsignaturefake= | |
230 | =/59v | |
231 | -----END PGP SIGNATURE----- | |
232 | EOF | |
233 | ||
234 | test_expect_success 'set up faked signed tag' ' | |
235 | ||
236 | cat signed-tag-import | git fast-import | |
237 | ||
238 | ' | |
239 | ||
240 | test_expect_success 'signed-tags=abort' ' | |
241 | ||
d492b31c | 242 | test_must_fail git fast-export --signed-tags=abort sign-your-name |
f2dc849e JS |
243 | |
244 | ' | |
245 | ||
ee4bc371 | 246 | test_expect_success 'signed-tags=verbatim' ' |
f2dc849e | 247 | |
ee4bc371 | 248 | git fast-export --signed-tags=verbatim sign-your-name > output && |
f2dc849e JS |
249 | grep PGP output |
250 | ||
251 | ' | |
252 | ||
253 | test_expect_success 'signed-tags=strip' ' | |
254 | ||
255 | git fast-export --signed-tags=strip sign-your-name > output && | |
256 | ! grep PGP output | |
257 | ||
258 | ' | |
259 | ||
cd16c59b JK |
260 | test_expect_success 'signed-tags=warn-strip' ' |
261 | git fast-export --signed-tags=warn-strip sign-your-name >output 2>err && | |
262 | ! grep PGP output && | |
263 | test -s err | |
264 | ' | |
265 | ||
03db4525 AG |
266 | test_expect_success 'setup submodule' ' |
267 | ||
268 | git checkout -f master && | |
269 | mkdir sub && | |
4c367c6a JH |
270 | ( |
271 | cd sub && | |
272 | git init && | |
273 | echo test file > file && | |
274 | git add file && | |
275 | git commit -m sub_initial | |
276 | ) && | |
c7b793a1 | 277 | git submodule add "$(pwd)/sub" sub && |
03db4525 AG |
278 | git commit -m initial && |
279 | test_tick && | |
4c367c6a JH |
280 | ( |
281 | cd sub && | |
282 | echo more data >> file && | |
283 | git add file && | |
284 | git commit -m sub_second | |
285 | ) && | |
03db4525 AG |
286 | git add sub && |
287 | git commit -m second | |
288 | ||
289 | ' | |
290 | ||
291 | test_expect_success 'submodule fast-export | fast-import' ' | |
292 | ||
293 | SUBENT1=$(git ls-tree master^ sub) && | |
294 | SUBENT2=$(git ls-tree master sub) && | |
295 | rm -rf new && | |
296 | mkdir new && | |
297 | git --git-dir=new/.git init && | |
a4d4e32a | 298 | git fast-export --signed-tags=strip --all >actual && |
03db4525 AG |
299 | (cd new && |
300 | git fast-import && | |
301 | test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" && | |
302 | test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" && | |
303 | git checkout master && | |
304 | git submodule init && | |
305 | git submodule update && | |
a4d4e32a | 306 | cmp sub/file ../sub/file) <actual |
03db4525 AG |
307 | |
308 | ' | |
309 | ||
91e80b98 JH |
310 | GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME |
311 | GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME | |
ae7c5dce AG |
312 | |
313 | test_expect_success 'setup copies' ' | |
314 | ||
ae7c5dce AG |
315 | git checkout -b copy rein && |
316 | git mv file file3 && | |
317 | git commit -m move1 && | |
318 | test_tick && | |
319 | cp file2 file4 && | |
320 | git add file4 && | |
321 | git mv file2 file5 && | |
322 | git commit -m copy1 && | |
323 | test_tick && | |
324 | cp file3 file6 && | |
325 | git add file6 && | |
326 | git commit -m copy2 && | |
327 | test_tick && | |
328 | echo more text >> file6 && | |
329 | echo even more text >> file6 && | |
330 | git add file6 && | |
331 | git commit -m modify && | |
332 | test_tick && | |
333 | cp file6 file7 && | |
334 | echo test >> file7 && | |
335 | git add file7 && | |
336 | git commit -m copy_modify | |
337 | ||
338 | ' | |
339 | ||
340 | test_expect_success 'fast-export -C -C | fast-import' ' | |
341 | ||
342 | ENTRY=$(git rev-parse --verify copy) && | |
343 | rm -rf new && | |
344 | mkdir new && | |
345 | git --git-dir=new/.git init && | |
346 | git fast-export -C -C --signed-tags=strip --all > output && | |
b3e8ca89 | 347 | grep "^C file2 file4\$" output && |
ae7c5dce AG |
348 | cat output | |
349 | (cd new && | |
350 | git fast-import && | |
351 | test $ENTRY = $(git rev-parse --verify refs/heads/copy)) | |
352 | ||
353 | ' | |
354 | ||
2075ffb5 | 355 | test_expect_success 'fast-export | fast-import when master is tagged' ' |
283b9532 MV |
356 | |
357 | git tag -m msg last && | |
358 | git fast-export -C -C --signed-tags=strip --all > output && | |
359 | test $(grep -c "^tag " output) = 3 | |
360 | ||
361 | ' | |
362 | ||
4e46a8d6 JS |
363 | cat > tag-content << EOF |
364 | object $(git rev-parse HEAD) | |
365 | type commit | |
366 | tag rosten | |
367 | EOF | |
368 | ||
369 | test_expect_success 'cope with tagger-less tags' ' | |
370 | ||
371 | TAG=$(git hash-object -t tag -w tag-content) && | |
372 | git update-ref refs/tags/sonnenschein $TAG && | |
373 | git fast-export -C -C --signed-tags=strip --all > output && | |
374 | test $(grep -c "^tag " output) = 4 && | |
375 | ! grep "Unspecified Tagger" output && | |
376 | git fast-export -C -C --signed-tags=strip --all \ | |
377 | --fake-missing-tagger > output && | |
378 | test $(grep -c "^tag " output) = 4 && | |
379 | grep "Unspecified Tagger" output | |
380 | ||
381 | ' | |
382 | ||
25e0ca5d EN |
383 | test_expect_success 'setup for limiting exports by PATH' ' |
384 | mkdir limit-by-paths && | |
4c367c6a JH |
385 | ( |
386 | cd limit-by-paths && | |
387 | git init && | |
388 | echo hi > there && | |
389 | git add there && | |
390 | git commit -m "First file" && | |
391 | echo foo > bar && | |
392 | git add bar && | |
393 | git commit -m "Second file" && | |
394 | git tag -a -m msg mytag && | |
395 | echo morefoo >> bar && | |
396 | git add bar && | |
397 | git commit -m "Change to second file" | |
398 | ) | |
25e0ca5d EN |
399 | ' |
400 | ||
401 | cat > limit-by-paths/expected << EOF | |
402 | blob | |
403 | mark :1 | |
404 | data 3 | |
405 | hi | |
406 | ||
407 | reset refs/tags/mytag | |
408 | commit refs/tags/mytag | |
409 | mark :2 | |
410 | author A U Thor <author@example.com> 1112912713 -0700 | |
411 | committer C O Mitter <committer@example.com> 1112912713 -0700 | |
412 | data 11 | |
413 | First file | |
414 | M 100644 :1 there | |
415 | ||
416 | EOF | |
417 | ||
418 | test_expect_success 'dropping tag of filtered out object' ' | |
4c367c6a | 419 | ( |
25e0ca5d EN |
420 | cd limit-by-paths && |
421 | git fast-export --tag-of-filtered-object=drop mytag -- there > output && | |
9ff10fc8 | 422 | test_cmp expected output |
4c367c6a | 423 | ) |
25e0ca5d EN |
424 | ' |
425 | ||
426 | cat >> limit-by-paths/expected << EOF | |
427 | tag mytag | |
428 | from :2 | |
429 | tagger C O Mitter <committer@example.com> 1112912713 -0700 | |
430 | data 4 | |
431 | msg | |
432 | ||
433 | EOF | |
434 | ||
435 | test_expect_success 'rewriting tag of filtered out object' ' | |
4c367c6a | 436 | ( |
25e0ca5d EN |
437 | cd limit-by-paths && |
438 | git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && | |
9ff10fc8 | 439 | test_cmp expected output |
4c367c6a | 440 | ) |
25e0ca5d EN |
441 | ' |
442 | ||
1f30c904 EN |
443 | test_expect_success 'rewrite tag predating pathspecs to nothing' ' |
444 | test_create_repo rewrite_tag_predating_pathspecs && | |
445 | ( | |
446 | cd rewrite_tag_predating_pathspecs && | |
447 | ||
448 | test_commit initial && | |
449 | ||
450 | git tag -a -m "Some old tag" v0.0.0.0.0.0.1 && | |
451 | ||
452 | test_commit bar && | |
453 | ||
454 | git fast-export --tag-of-filtered-object=rewrite --all -- bar.t >output && | |
455 | grep from.$ZERO_OID output | |
456 | ) | |
457 | ' | |
458 | ||
25e0ca5d EN |
459 | cat > limit-by-paths/expected << EOF |
460 | blob | |
461 | mark :1 | |
462 | data 4 | |
463 | foo | |
464 | ||
465 | blob | |
466 | mark :2 | |
467 | data 3 | |
468 | hi | |
469 | ||
470 | reset refs/heads/master | |
471 | commit refs/heads/master | |
472 | mark :3 | |
473 | author A U Thor <author@example.com> 1112912713 -0700 | |
474 | committer C O Mitter <committer@example.com> 1112912713 -0700 | |
475 | data 12 | |
476 | Second file | |
477 | M 100644 :1 bar | |
478 | M 100644 :2 there | |
479 | ||
480 | EOF | |
481 | ||
482 | test_expect_failure 'no exact-ref revisions included' ' | |
4c367c6a JH |
483 | ( |
484 | cd limit-by-paths && | |
485 | git fast-export master~2..master~1 > output && | |
9ff10fc8 | 486 | test_cmp expected output |
4c367c6a | 487 | ) |
25e0ca5d EN |
488 | ' |
489 | ||
4087a02e EN |
490 | test_expect_success 'path limiting with import-marks does not lose unmodified files' ' |
491 | git checkout -b simple marks~2 && | |
492 | git fast-export --export-marks=marks simple -- file > /dev/null && | |
493 | echo more content >> file && | |
494 | test_tick && | |
495 | git commit -mnext file && | |
a4d4e32a PK |
496 | git fast-export --import-marks=marks simple -- file file0 >actual && |
497 | grep file0 actual | |
4087a02e EN |
498 | ' |
499 | ||
cd13762d EN |
500 | test_expect_success 'avoid corrupt stream with non-existent mark' ' |
501 | test_create_repo avoid_non_existent_mark && | |
502 | ( | |
503 | cd avoid_non_existent_mark && | |
504 | ||
505 | test_commit important-path && | |
506 | ||
507 | test_commit ignored && | |
508 | ||
509 | git branch A && | |
510 | git branch B && | |
511 | ||
512 | echo foo >>important-path.t && | |
513 | git add important-path.t && | |
514 | test_commit more changes && | |
515 | ||
516 | git fast-export --all -- important-path.t | git fast-import --force | |
517 | ) | |
518 | ' | |
519 | ||
7f40ab09 EN |
520 | test_expect_success 'full-tree re-shows unmodified files' ' |
521 | git checkout -f simple && | |
a4d4e32a PK |
522 | git fast-export --full-tree simple >actual && |
523 | test $(grep -c file0 actual) -eq 3 | |
7f40ab09 EN |
524 | ' |
525 | ||
41a5c70f EFL |
526 | test_expect_success 'set-up a few more tags for tag export tests' ' |
527 | git checkout -f master && | |
c7b793a1 | 528 | HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") && |
41a5c70f EFL |
529 | git tag tree_tag -m "tagging a tree" $HEAD_TREE && |
530 | git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && | |
531 | git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && | |
532 | git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj | |
533 | ' | |
534 | ||
02c48cd6 EN |
535 | test_expect_success 'tree_tag' ' |
536 | mkdir result && | |
537 | (cd result && git init) && | |
538 | git fast-export tree_tag > fe-stream && | |
539 | (cd result && git fast-import < ../fe-stream) | |
540 | ' | |
541 | ||
41a5c70f | 542 | # NEEDSWORK: not just check return status, but validate the output |
8d7d33c1 | 543 | # Note that these tests DO NOTHING other than print a warning that |
7a40cf15 | 544 | # they are omitting the one tag we asked them to export (because the |
8d7d33c1 EN |
545 | # tags resolve to a tree). They exist just to make sure we do not |
546 | # abort but instead just warn. | |
c0582c53 | 547 | test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' |
1982467d EFL |
548 | test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' |
549 | test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' | |
41a5c70f | 550 | |
8d7d33c1 EN |
551 | test_expect_success 'handling tags of blobs' ' |
552 | git tag -a -m "Tag of a blob" blobtag $(git rev-parse master:file) && | |
553 | git fast-export blobtag >actual && | |
554 | cat >expect <<-EOF && | |
555 | blob | |
556 | mark :1 | |
557 | data 9 | |
558 | die Luft | |
559 | ||
560 | tag blobtag | |
561 | from :1 | |
562 | tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE | |
563 | data 14 | |
564 | Tag of a blob | |
565 | ||
566 | EOF | |
567 | test_cmp expect actual | |
568 | ' | |
569 | ||
941790d7 | 570 | test_expect_success 'handling nested tags' ' |
8d7d33c1 EN |
571 | git tag -a -m "This is a nested tag" nested muss && |
572 | git fast-export --mark-tags nested >output && | |
573 | grep "^from $ZERO_OID$" output && | |
574 | grep "^tag nested$" output >tag_lines && | |
575 | test_line_count = 2 tag_lines | |
576 | ' | |
577 | ||
889c6f0e | 578 | test_expect_success 'directory becomes symlink' ' |
f15652d9 EN |
579 | git init dirtosymlink && |
580 | git init result && | |
581 | ( | |
582 | cd dirtosymlink && | |
583 | mkdir foo && | |
584 | mkdir bar && | |
585 | echo hello > foo/world && | |
586 | echo hello > bar/world && | |
587 | git add foo/world bar/world && | |
588 | git commit -q -mone && | |
589 | git rm -r foo && | |
889c6f0e | 590 | test_ln_s_add bar foo && |
f15652d9 EN |
591 | git commit -q -mtwo |
592 | ) && | |
593 | ( | |
594 | cd dirtosymlink && | |
595 | git fast-export master -- foo | | |
596 | (cd ../result && git fast-import --quiet) | |
597 | ) && | |
598 | (cd result && git show master:foo) | |
599 | ' | |
600 | ||
6280dfdc JK |
601 | test_expect_success 'fast-export quotes pathnames' ' |
602 | git init crazy-paths && | |
e1d911dd | 603 | test_config -C crazy-paths core.protectNTFS false && |
6280dfdc | 604 | (cd crazy-paths && |
c7b793a1 | 605 | blob=$(echo foo | git hash-object -w --stdin) && |
35edce20 | 606 | git -c core.protectNTFS=false update-index --add \ |
6280dfdc JK |
607 | --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \ |
608 | --cacheinfo 100644 $blob "path with \"quote\"" \ | |
609 | --cacheinfo 100644 $blob "path with \\backslash" \ | |
610 | --cacheinfo 100644 $blob "path with space" && | |
611 | git commit -m addition && | |
94221d22 | 612 | git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index && |
6280dfdc JK |
613 | git read-tree --empty && |
614 | git update-index -z --index-info <index && | |
615 | git commit -m rename && | |
616 | git read-tree --empty && | |
617 | git commit -m deletion && | |
ff59f6da | 618 | git fast-export -M HEAD >export.out && |
6280dfdc JK |
619 | git rev-list HEAD >expect && |
620 | git init result && | |
621 | cd result && | |
622 | git fast-import <../export.out && | |
623 | git rev-list HEAD >actual && | |
624 | test_cmp ../expect actual | |
625 | ) | |
626 | ' | |
627 | ||
5d3698ff | 628 | test_expect_success 'test bidirectionality' ' |
5d3698ff | 629 | git init marks-test && |
208d6924 EN |
630 | git fast-export --export-marks=marks-cur --import-marks-if-exists=marks-cur --branches | \ |
631 | git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks-if-exists=marks-new && | |
5d3698ff FC |
632 | (cd marks-test && |
633 | git reset --hard && | |
634 | echo Wohlauf > file && | |
635 | git commit -a -m "back in time") && | |
208d6924 EN |
636 | git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks-if-exists=marks-new --branches | \ |
637 | git fast-import --export-marks=marks-cur --import-marks-if-exists=marks-cur | |
5d3698ff FC |
638 | ' |
639 | ||
49266e8a FC |
640 | cat > expected << EOF |
641 | blob | |
642 | mark :13 | |
643 | data 5 | |
644 | bump | |
645 | ||
646 | commit refs/heads/master | |
647 | mark :14 | |
648 | author A U Thor <author@example.com> 1112912773 -0700 | |
649 | committer C O Mitter <committer@example.com> 1112912773 -0700 | |
650 | data 5 | |
651 | bump | |
652 | from :12 | |
653 | M 100644 :13 file | |
654 | ||
655 | EOF | |
656 | ||
657 | test_expect_success 'avoid uninteresting refs' ' | |
658 | > tmp-marks && | |
659 | git fast-export --import-marks=tmp-marks \ | |
660 | --export-marks=tmp-marks master > /dev/null && | |
661 | git tag v1.0 && | |
662 | git branch uninteresting && | |
663 | echo bump > file && | |
664 | git commit -a -m bump && | |
665 | git fast-export --import-marks=tmp-marks \ | |
666 | --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual && | |
667 | test_cmp expected actual | |
668 | ' | |
669 | ||
f28e7c90 FC |
670 | cat > expected << EOF |
671 | reset refs/heads/master | |
672 | from :14 | |
673 | ||
674 | EOF | |
675 | ||
676 | test_expect_success 'refs are updated even if no commits need to be exported' ' | |
677 | > tmp-marks && | |
678 | git fast-export --import-marks=tmp-marks \ | |
679 | --export-marks=tmp-marks master > /dev/null && | |
680 | git fast-export --import-marks=tmp-marks \ | |
681 | --export-marks=tmp-marks master > actual && | |
682 | test_cmp expected actual | |
683 | ' | |
684 | ||
03e9010c | 685 | test_expect_success 'use refspec' ' |
a4d4e32a PK |
686 | git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 && |
687 | grep "^commit " actual2 | sort | uniq >actual && | |
03e9010c FC |
688 | echo "commit refs/heads/foobar" > expected && |
689 | test_cmp expected actual | |
690 | ' | |
691 | ||
fdf31b63 | 692 | test_expect_success 'delete ref because entire history excluded' ' |
60ed2643 | 693 | git branch to-delete && |
fdf31b63 EN |
694 | git fast-export to-delete ^to-delete >actual && |
695 | cat >expected <<-EOF && | |
696 | reset refs/heads/to-delete | |
831279d3 | 697 | from $ZERO_OID |
fdf31b63 EN |
698 | |
699 | EOF | |
700 | test_cmp expected actual | |
701 | ' | |
702 | ||
703 | test_expect_success 'delete refspec' ' | |
704 | git fast-export --refspec :refs/heads/to-delete >actual && | |
705 | cat >expected <<-EOF && | |
60ed2643 | 706 | reset refs/heads/to-delete |
831279d3 | 707 | from $ZERO_OID |
60ed2643 FC |
708 | |
709 | EOF | |
710 | test_cmp expected actual | |
711 | ' | |
712 | ||
b3e8ca89 JT |
713 | test_expect_success 'when using -C, do not declare copy when source of copy is also modified' ' |
714 | test_create_repo src && | |
715 | echo a_line >src/file.txt && | |
716 | git -C src add file.txt && | |
717 | git -C src commit -m 1st_commit && | |
718 | ||
719 | cp src/file.txt src/file2.txt && | |
720 | echo another_line >>src/file.txt && | |
721 | git -C src add file.txt file2.txt && | |
722 | git -C src commit -m 2nd_commit && | |
723 | ||
724 | test_create_repo dst && | |
a4d4e32a PK |
725 | git -C src fast-export --all -C >actual && |
726 | git -C dst fast-import <actual && | |
b3e8ca89 JT |
727 | git -C src show >expected && |
728 | git -C dst show >actual && | |
729 | test_cmp expected actual | |
730 | ' | |
731 | ||
be011bbe MÅ |
732 | test_expect_success 'merge commit gets exported with --import-marks' ' |
733 | test_create_repo merging && | |
734 | ( | |
735 | cd merging && | |
736 | test_commit initial && | |
737 | git checkout -b topic && | |
738 | test_commit on-topic && | |
739 | git checkout master && | |
740 | test_commit on-master && | |
741 | test_tick && | |
742 | git merge --no-ff -m Yeah topic && | |
743 | ||
744 | echo ":1 $(git rev-parse HEAD^^)" >marks && | |
745 | git fast-export --import-marks=marks master >out && | |
746 | grep Yeah out | |
747 | ) | |
748 | ' | |
749 | ||
f2dc849e | 750 | test_done |