]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9350-fast-export.sh
Merge branch 'js/update-index-ignore-removal-for-skip-worktree'
[thirdparty/git.git] / t / t9350-fast-export.sh
CommitLineData
f2dc849e
JS
1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
eaa2a6fc 6test_description='git fast-export'
f2dc849e
JS
7. ./test-lib.sh
8
9test_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
38test_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
56test_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
69test_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
83test_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
96test_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
107test_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
117test_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 124test_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 &&
32615ce7
EN
135 # The commit object, if not re-encoded, would be 240 bytes.
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.
140 test 221 -eq "$(git cat-file -s i18n)" &&
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
148test_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
157test_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 &&
167 # The commit object, if not re-encoded, is 240 bytes.
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...
172 test 240 -eq "$(git cat-file -s i18n-no-recoding)" &&
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
180test_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.
195 test 252 -eq "$(git cat-file -s i18n-invalid)" &&
196 # ...and check for the original special bytes
197 grep $(printf "\360") actual &&
198 grep $(printf "\377") actual)
199'
200
df6a7ff7
PB
201test_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
219cat > signed-tag-import << EOF
220tag sign-your-name
221from $(git rev-parse HEAD)
222tagger C O Mitter <committer@example.com> 1112911993 -0700
223data 210
224A message for a sign
225-----BEGIN PGP SIGNATURE-----
226Version: GnuPG v1.4.5 (GNU/Linux)
227
228fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
229aturefakedsignaturefake=
230=/59v
231-----END PGP SIGNATURE-----
232EOF
233
234test_expect_success 'set up faked signed tag' '
235
236 cat signed-tag-import | git fast-import
237
238'
239
240test_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 246test_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
253test_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
260test_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
266test_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
291test_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
310GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME
311GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME
ae7c5dce
AG
312
313test_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
340test_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 355test_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
363cat > tag-content << EOF
364object $(git rev-parse HEAD)
365type commit
366tag rosten
367EOF
368
369test_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
383test_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
401cat > limit-by-paths/expected << EOF
402blob
403mark :1
404data 3
405hi
406
407reset refs/tags/mytag
408commit refs/tags/mytag
409mark :2
410author A U Thor <author@example.com> 1112912713 -0700
411committer C O Mitter <committer@example.com> 1112912713 -0700
412data 11
413First file
414M 100644 :1 there
415
416EOF
417
418test_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
426cat >> limit-by-paths/expected << EOF
427tag mytag
428from :2
429tagger C O Mitter <committer@example.com> 1112912713 -0700
430data 4
431msg
432
433EOF
434
435test_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
443test_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
459cat > limit-by-paths/expected << EOF
460blob
461mark :1
462data 4
463foo
464
465blob
466mark :2
467data 3
468hi
469
470reset refs/heads/master
471commit refs/heads/master
472mark :3
473author A U Thor <author@example.com> 1112912713 -0700
474committer C O Mitter <committer@example.com> 1112912713 -0700
475data 12
476Second file
477M 100644 :1 bar
478M 100644 :2 there
479
480EOF
481
482test_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
490test_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
500test_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
520test_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
526test_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
535test_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
EN
543# Note that these tests DO NOTHING other than print a warning that
544# they are ommitting the one tag we asked them to export (because the
545# tags resolve to a tree). They exist just to make sure we do not
546# abort but instead just warn.
c0582c53 547test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
1982467d
EFL
548test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag'
549test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
41a5c70f 550
8d7d33c1
EN
551test_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 570test_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 578test_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
601test_expect_success 'fast-export quotes pathnames' '
602 git init crazy-paths &&
603 (cd crazy-paths &&
c7b793a1 604 blob=$(echo foo | git hash-object -w --stdin) &&
6280dfdc
JK
605 git update-index --add \
606 --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \
607 --cacheinfo 100644 $blob "path with \"quote\"" \
608 --cacheinfo 100644 $blob "path with \\backslash" \
609 --cacheinfo 100644 $blob "path with space" &&
610 git commit -m addition &&
94221d22 611 git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index &&
6280dfdc
JK
612 git read-tree --empty &&
613 git update-index -z --index-info <index &&
614 git commit -m rename &&
615 git read-tree --empty &&
616 git commit -m deletion &&
ff59f6da 617 git fast-export -M HEAD >export.out &&
6280dfdc
JK
618 git rev-list HEAD >expect &&
619 git init result &&
620 cd result &&
621 git fast-import <../export.out &&
622 git rev-list HEAD >actual &&
623 test_cmp ../expect actual
624 )
625'
626
5d3698ff 627test_expect_success 'test bidirectionality' '
5d3698ff 628 git init marks-test &&
208d6924
EN
629 git fast-export --export-marks=marks-cur --import-marks-if-exists=marks-cur --branches | \
630 git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks-if-exists=marks-new &&
5d3698ff
FC
631 (cd marks-test &&
632 git reset --hard &&
633 echo Wohlauf > file &&
634 git commit -a -m "back in time") &&
208d6924
EN
635 git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks-if-exists=marks-new --branches | \
636 git fast-import --export-marks=marks-cur --import-marks-if-exists=marks-cur
5d3698ff
FC
637'
638
49266e8a
FC
639cat > expected << EOF
640blob
641mark :13
642data 5
643bump
644
645commit refs/heads/master
646mark :14
647author A U Thor <author@example.com> 1112912773 -0700
648committer C O Mitter <committer@example.com> 1112912773 -0700
649data 5
650bump
651from :12
652M 100644 :13 file
653
654EOF
655
656test_expect_success 'avoid uninteresting refs' '
657 > tmp-marks &&
658 git fast-export --import-marks=tmp-marks \
659 --export-marks=tmp-marks master > /dev/null &&
660 git tag v1.0 &&
661 git branch uninteresting &&
662 echo bump > file &&
663 git commit -a -m bump &&
664 git fast-export --import-marks=tmp-marks \
665 --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual &&
666 test_cmp expected actual
667'
668
f28e7c90
FC
669cat > expected << EOF
670reset refs/heads/master
671from :14
672
673EOF
674
675test_expect_success 'refs are updated even if no commits need to be exported' '
676 > tmp-marks &&
677 git fast-export --import-marks=tmp-marks \
678 --export-marks=tmp-marks master > /dev/null &&
679 git fast-export --import-marks=tmp-marks \
680 --export-marks=tmp-marks master > actual &&
681 test_cmp expected actual
682'
683
03e9010c 684test_expect_success 'use refspec' '
a4d4e32a
PK
685 git fast-export --refspec refs/heads/master:refs/heads/foobar master >actual2 &&
686 grep "^commit " actual2 | sort | uniq >actual &&
03e9010c
FC
687 echo "commit refs/heads/foobar" > expected &&
688 test_cmp expected actual
689'
690
fdf31b63 691test_expect_success 'delete ref because entire history excluded' '
60ed2643 692 git branch to-delete &&
fdf31b63
EN
693 git fast-export to-delete ^to-delete >actual &&
694 cat >expected <<-EOF &&
695 reset refs/heads/to-delete
696 from 0000000000000000000000000000000000000000
697
698 EOF
699 test_cmp expected actual
700'
701
702test_expect_success 'delete refspec' '
703 git fast-export --refspec :refs/heads/to-delete >actual &&
704 cat >expected <<-EOF &&
60ed2643
FC
705 reset refs/heads/to-delete
706 from 0000000000000000000000000000000000000000
707
708 EOF
709 test_cmp expected actual
710'
711
b3e8ca89
JT
712test_expect_success 'when using -C, do not declare copy when source of copy is also modified' '
713 test_create_repo src &&
714 echo a_line >src/file.txt &&
715 git -C src add file.txt &&
716 git -C src commit -m 1st_commit &&
717
718 cp src/file.txt src/file2.txt &&
719 echo another_line >>src/file.txt &&
720 git -C src add file.txt file2.txt &&
721 git -C src commit -m 2nd_commit &&
722
723 test_create_repo dst &&
a4d4e32a
PK
724 git -C src fast-export --all -C >actual &&
725 git -C dst fast-import <actual &&
b3e8ca89
JT
726 git -C src show >expected &&
727 git -C dst show >actual &&
728 test_cmp expected actual
729'
730
be011bbe
731test_expect_success 'merge commit gets exported with --import-marks' '
732 test_create_repo merging &&
733 (
734 cd merging &&
735 test_commit initial &&
736 git checkout -b topic &&
737 test_commit on-topic &&
738 git checkout master &&
739 test_commit on-master &&
740 test_tick &&
741 git merge --no-ff -m Yeah topic &&
742
743 echo ":1 $(git rev-parse HEAD^^)" >marks &&
744 git fast-export --import-marks=marks master >out &&
745 grep Yeah out
746 )
747'
748
f2dc849e 749test_done