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