]> git.ipfire.org Git - thirdparty/git.git/blame - t/t9300-fast-import.sh
fast-import: disallow "feature export-marks" by default
[thirdparty/git.git] / t / t9300-fast-import.sh
CommitLineData
50aee995
SP
1#!/bin/sh
2#
3# Copyright (c) 2007 Shawn Pearce
4#
5
eaa2a6fc 6test_description='test git fast-import utility'
50aee995 7. ./test-lib.sh
bfdbee98 8. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
50aee995 9
05880b02
JS
10verify_packs () {
11 for p in .git/objects/pack/*.pack
12 do
13 git verify-pack "$@" "$p" || return
14 done
15}
16
8232dc42
SP
17file2_data='file2
18second line of EOF'
19
20file3_data='EOF
21in 3rd file
22 END'
23
24file4_data=abcd
25file4_len=4
26
b715cfbb
SP
27file5_data='an inline file.
28 we should see it later.'
29
30file6_data='#!/bin/sh
31echo "$@"'
32
50aee995
SP
33###
34### series A
35###
36
85c62395 37test_expect_success 'empty stream succeeds' '
d9545c7f 38 git config fastimport.unpackLimit 0 &&
85c62395
DB
39 git fast-import </dev/null
40'
41
b7090430
JK
42test_expect_success 'truncated stream complains' '
43 echo "tag foo" | test_must_fail git fast-import
44'
45
d67824fe 46test_expect_success 'A: create pack from stdin' '
68297e0f
JS
47 test_tick &&
48 cat >input <<-INPUT_END &&
49 blob
50 mark :2
51 data <<EOF
52 $file2_data
53 EOF
54
55 blob
56 mark :3
57 data <<END
58 $file3_data
59 END
60
61 blob
62 mark :4
63 data $file4_len
64 $file4_data
65 commit refs/heads/master
66 mark :5
67 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
68 data <<COMMIT
69 initial
70 COMMIT
71
72 M 644 :2 file2
73 M 644 :3 file3
74 M 755 :4 file4
75
76 tag series-A
77 from :5
78 data <<EOF
79 An annotated tag without a tagger
80 EOF
81
82 tag series-A-blob
83 from :3
84 data <<EOF
85 An annotated tag that annotates a blob.
86 EOF
87
88 INPUT_END
d67824fe
JS
89 git fast-import --export-marks=marks.out <input &&
90 git whatchanged master
91'
05880b02
JS
92
93test_expect_success 'A: verify pack' '
94 verify_packs
95'
50aee995 96
d67824fe 97test_expect_success 'A: verify commit' '
68297e0f
JS
98 cat >expect <<-EOF &&
99 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
100 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
101
102 initial
103 EOF
d67824fe
JS
104 git cat-file commit master | sed 1d >actual &&
105 test_cmp expect actual
106'
50aee995 107
d67824fe 108test_expect_success 'A: verify tree' '
68297e0f
JS
109 cat >expect <<-EOF &&
110 100644 blob file2
111 100644 blob file3
112 100755 blob file4
113 EOF
d67824fe
JS
114 git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
115 test_cmp expect actual
116'
50aee995 117
d67824fe 118test_expect_success 'A: verify file2' '
68297e0f 119 echo "$file2_data" >expect &&
ec2c10be
JS
120 git cat-file blob master:file2 >actual &&
121 test_cmp expect actual
d67824fe 122'
50aee995 123
d67824fe 124test_expect_success 'A: verify file3' '
68297e0f 125 echo "$file3_data" >expect &&
ec2c10be
JS
126 git cat-file blob master:file3 >actual &&
127 test_cmp expect actual
d67824fe 128'
50aee995 129
d67824fe 130test_expect_success 'A: verify file4' '
68297e0f 131 printf "$file4_data" >expect &&
ec2c10be
JS
132 git cat-file blob master:file4 >actual &&
133 test_cmp expect actual
d67824fe 134'
50aee995 135
88fbf67b 136test_expect_success 'A: verify tag/series-A' '
68297e0f
JS
137 cat >expect <<-EOF &&
138 object $(git rev-parse refs/heads/master)
139 type commit
140 tag series-A
141
142 An annotated tag without a tagger
143 EOF
88fbf67b
JH
144 git cat-file tag tags/series-A >actual &&
145 test_cmp expect actual
146'
147
2efe38e7 148test_expect_success 'A: verify tag/series-A-blob' '
68297e0f
JS
149 cat >expect <<-EOF &&
150 object $(git rev-parse refs/heads/master:file3)
151 type blob
152 tag series-A-blob
153
154 An annotated tag that annotates a blob.
155 EOF
2efe38e7
DI
156 git cat-file tag tags/series-A-blob >actual &&
157 test_cmp expect actual
158'
159
d67824fe 160test_expect_success 'A: verify marks output' '
68297e0f 161 cat >expect <<-EOF &&
80a6b3f0
EP
162 :2 $(git rev-parse --verify master:file2)
163 :3 $(git rev-parse --verify master:file3)
164 :4 $(git rev-parse --verify master:file4)
165 :5 $(git rev-parse --verify master^0)
68297e0f 166 EOF
d67824fe
JS
167 test_cmp expect marks.out
168'
50aee995 169
d67824fe
JS
170test_expect_success 'A: verify marks import' '
171 git fast-import \
e8438420
SP
172 --import-marks=marks.out \
173 --export-marks=marks.new \
174 </dev/null &&
d67824fe
JS
175 test_cmp expect marks.new
176'
e8438420 177
d67824fe 178test_expect_success 'A: tag blob by sha1' '
68297e0f
JS
179 test_tick &&
180 new_blob=$(echo testing | git hash-object --stdin) &&
181 cat >input <<-INPUT_END &&
182 tag series-A-blob-2
183 from $(git rev-parse refs/heads/master:file3)
184 data <<EOF
185 Tag blob by sha1.
186 EOF
187
188 blob
189 mark :6
190 data <<EOF
191 testing
192 EOF
193
194 commit refs/heads/new_blob
195 committer <> 0 +0000
196 data 0
197 M 644 :6 new_blob
198 #pretend we got sha1 from fast-import
199 ls "new_blob"
200
201 tag series-A-blob-3
202 from $new_blob
203 data <<EOF
204 Tag new_blob.
205 EOF
206 INPUT_END
207
208 cat >expect <<-EOF &&
209 object $(git rev-parse refs/heads/master:file3)
210 type blob
211 tag series-A-blob-2
212
213 Tag blob by sha1.
214 object $new_blob
215 type blob
216 tag series-A-blob-3
217
218 Tag new_blob.
219 EOF
220
d67824fe 221 git fast-import <input &&
2efe38e7 222 git cat-file tag tags/series-A-blob-2 >actual &&
6c447f63 223 git cat-file tag tags/series-A-blob-3 >>actual &&
d67824fe
JS
224 test_cmp expect actual
225'
2efe38e7 226
68297e0f
JS
227test_expect_success 'A: verify marks import does not crash' '
228 test_tick &&
229 cat >input <<-INPUT_END &&
230 commit refs/heads/verify--import-marks
231 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
232 data <<COMMIT
233 recreate from :5
234 COMMIT
235
236 from :5
237 M 755 :2 copy-of-file2
aac65ed1 238
68297e0f 239 INPUT_END
aac65ed1 240
d67824fe
JS
241 git fast-import --import-marks=marks.out <input &&
242 git whatchanged verify--import-marks
243'
05880b02
JS
244
245test_expect_success 'A: verify pack' '
246 verify_packs
247'
248
d67824fe 249test_expect_success 'A: verify diff' '
68297e0f
JS
250 cat >expect <<-EOF &&
251 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
252 EOF
253 git diff-tree -M -r master verify--import-marks >actual &&
d67824fe 254 compare_diff_raw expect actual &&
80a6b3f0
EP
255 test $(git rev-parse --verify master:file2) \
256 = $(git rev-parse --verify verify--import-marks:copy-of-file2)
d67824fe 257'
aac65ed1 258
7e7db5e4 259test_expect_success 'A: export marks with large values' '
68297e0f
JS
260 test_tick &&
261 mt=$(git hash-object --stdin < /dev/null) &&
262 >input.blob &&
263 >marks.exp &&
264 >tree.exp &&
265
266 cat >input.commit <<-EOF &&
267 commit refs/heads/verify--dump-marks
268 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
269 data <<COMMIT
270 test the sparse array dumping routines with exponentially growing marks
271 COMMIT
272 EOF
273
274 i=0 l=4 m=6 n=7 &&
275 while test "$i" -lt 27
276 do
277 cat >>input.blob <<-EOF &&
278 blob
279 mark :$l
280 data 0
281 blob
282 mark :$m
283 data 0
284 blob
285 mark :$n
286 data 0
287 EOF
288 echo "M 100644 :$l l$i" >>input.commit &&
289 echo "M 100644 :$m m$i" >>input.commit &&
290 echo "M 100644 :$n n$i" >>input.commit &&
291
292 echo ":$l $mt" >>marks.exp &&
293 echo ":$m $mt" >>marks.exp &&
294 echo ":$n $mt" >>marks.exp &&
295
296 printf "100644 blob $mt\tl$i\n" >>tree.exp &&
297 printf "100644 blob $mt\tm$i\n" >>tree.exp &&
298 printf "100644 blob $mt\tn$i\n" >>tree.exp &&
299
300 l=$(($l + $l)) &&
301 m=$(($m + $m)) &&
302 n=$(($l + $n)) &&
303
304 i=$((1 + $i)) || return 1
305 done &&
306
307 sort tree.exp > tree.exp_s &&
308
7e7db5e4
RH
309 cat input.blob input.commit | git fast-import --export-marks=marks.large &&
310 git ls-tree refs/heads/verify--dump-marks >tree.out &&
311 test_cmp tree.exp_s tree.out &&
d67824fe
JS
312 test_cmp marks.exp marks.large
313'
7e7db5e4 314
50aee995
SP
315###
316### series B
317###
318
68297e0f
JS
319test_expect_success 'B: fail on invalid blob sha1' '
320 test_tick &&
321 cat >input <<-INPUT_END &&
322 commit refs/heads/branch
323 mark :1
324 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
325 data <<COMMIT
326 corrupt
327 COMMIT
328
329 from refs/heads/master
330 M 755 0000000000000000000000000000000000000001 zero1
50aee995 331
68297e0f 332 INPUT_END
50aee995 333
93e911f5 334 test_when_finished "rm -f .git/objects/pack_* .git/objects/index_*" &&
d67824fe 335 test_must_fail git fast-import <input
41ac414e 336'
50aee995 337
68297e0f
JS
338test_expect_success 'B: accept branch name "TEMP_TAG"' '
339 cat >input <<-INPUT_END &&
340 commit TEMP_TAG
341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
342 data <<COMMIT
343 tag base
344 COMMIT
345
346 from refs/heads/master
ea08a6fd 347
68297e0f 348 INPUT_END
ea08a6fd 349
93e911f5
JS
350 test_when_finished "rm -f .git/TEMP_TAG
351 git gc
352 git prune" &&
d67824fe
JS
353 git fast-import <input &&
354 test -f .git/TEMP_TAG &&
80a6b3f0 355 test $(git rev-parse master) = $(git rev-parse TEMP_TAG^)
d67824fe 356'
4cedb78c 357
4cedb78c 358test_expect_success 'B: accept empty committer' '
68297e0f
JS
359 cat >input <<-INPUT_END &&
360 commit refs/heads/empty-committer-1
361 committer <> $GIT_COMMITTER_DATE
362 data <<COMMIT
363 empty commit
364 COMMIT
365 INPUT_END
366
93e911f5
JS
367 test_when_finished "git update-ref -d refs/heads/empty-committer-1
368 git gc
369 git prune" &&
4cedb78c
DI
370 git fast-import <input &&
371 out=$(git fsck) &&
372 echo "$out" &&
373 test -z "$out"
374'
4cedb78c 375
17fb0072 376test_expect_success 'B: accept and fixup committer with no name' '
68297e0f
JS
377 cat >input <<-INPUT_END &&
378 commit refs/heads/empty-committer-2
379 committer <a@b.com> $GIT_COMMITTER_DATE
380 data <<COMMIT
381 empty commit
382 COMMIT
383 INPUT_END
384
93e911f5
JS
385 test_when_finished "git update-ref -d refs/heads/empty-committer-2
386 git gc
387 git prune" &&
4cedb78c
DI
388 git fast-import <input &&
389 out=$(git fsck) &&
390 echo "$out" &&
391 test -z "$out"
392'
4cedb78c 393
4b4963c0 394test_expect_success 'B: fail on invalid committer (1)' '
68297e0f
JS
395 cat >input <<-INPUT_END &&
396 commit refs/heads/invalid-committer
397 committer Name email> $GIT_COMMITTER_DATE
398 data <<COMMIT
399 empty commit
400 COMMIT
401 INPUT_END
402
93e911f5 403 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
4cedb78c
DI
404 test_must_fail git fast-import <input
405'
4cedb78c 406
4b4963c0 407test_expect_success 'B: fail on invalid committer (2)' '
68297e0f
JS
408 cat >input <<-INPUT_END &&
409 commit refs/heads/invalid-committer
410 committer Name <e<mail> $GIT_COMMITTER_DATE
411 data <<COMMIT
412 empty commit
413 COMMIT
414 INPUT_END
415
93e911f5 416 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
4cedb78c
DI
417 test_must_fail git fast-import <input
418'
4cedb78c 419
4b4963c0 420test_expect_success 'B: fail on invalid committer (3)' '
68297e0f
JS
421 cat >input <<-INPUT_END &&
422 commit refs/heads/invalid-committer
423 committer Name <email>> $GIT_COMMITTER_DATE
424 data <<COMMIT
425 empty commit
426 COMMIT
427 INPUT_END
428
93e911f5 429 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
4cedb78c
DI
430 test_must_fail git fast-import <input
431'
4cedb78c 432
4b4963c0 433test_expect_success 'B: fail on invalid committer (4)' '
68297e0f
JS
434 cat >input <<-INPUT_END &&
435 commit refs/heads/invalid-committer
436 committer Name <email $GIT_COMMITTER_DATE
437 data <<COMMIT
438 empty commit
439 COMMIT
440 INPUT_END
441
93e911f5 442 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
4cedb78c
DI
443 test_must_fail git fast-import <input
444'
4cedb78c 445
4b4963c0 446test_expect_success 'B: fail on invalid committer (5)' '
68297e0f
JS
447 cat >input <<-INPUT_END &&
448 commit refs/heads/invalid-committer
449 committer Name<email> $GIT_COMMITTER_DATE
450 data <<COMMIT
451 empty commit
452 COMMIT
453 INPUT_END
454
93e911f5 455 test_when_finished "git update-ref -d refs/heads/invalid-committer" &&
4cedb78c
DI
456 test_must_fail git fast-import <input
457'
4cedb78c 458
50aee995
SP
459###
460### series C
461###
462
d67824fe 463test_expect_success 'C: incremental import create pack from stdin' '
80a6b3f0
EP
464 newf=$(echo hi newf | git hash-object -w --stdin) &&
465 oldf=$(git rev-parse --verify master:file2) &&
68297e0f
JS
466 test_tick &&
467 cat >input <<-INPUT_END &&
468 commit refs/heads/branch
469 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
470 data <<COMMIT
471 second
472 COMMIT
473
474 from refs/heads/master
475 M 644 $oldf file2/oldf
476 M 755 $newf file2/newf
477 D file3
478
479 INPUT_END
480
d67824fe
JS
481 git fast-import <input &&
482 git whatchanged branch
483'
05880b02
JS
484
485test_expect_success 'C: verify pack' '
486 verify_packs
487'
488
d67824fe 489test_expect_success 'C: validate reuse existing blob' '
80a6b3f0
EP
490 test $newf = $(git rev-parse --verify branch:file2/newf) &&
491 test $oldf = $(git rev-parse --verify branch:file2/oldf)
d67824fe 492'
50aee995 493
d67824fe 494test_expect_success 'C: verify commit' '
68297e0f 495 cat >expect <<-EOF &&
80a6b3f0 496 parent $(git rev-parse --verify master^0)
68297e0f
JS
497 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
498 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
499
500 second
501 EOF
502
d67824fe
JS
503 git cat-file commit branch | sed 1d >actual &&
504 test_cmp expect actual
505'
50aee995 506
d67824fe 507test_expect_success 'C: validate rename result' '
68297e0f
JS
508 cat >expect <<-EOF &&
509 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
510 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
511 :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
512 EOF
513 git diff-tree -M -r master branch >actual &&
d67824fe
JS
514 compare_diff_raw expect actual
515'
50aee995 516
b715cfbb
SP
517###
518### series D
519###
520
d67824fe 521test_expect_success 'D: inline data in commit' '
68297e0f
JS
522 test_tick &&
523 cat >input <<-INPUT_END &&
524 commit refs/heads/branch
525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
526 data <<COMMIT
527 third
528 COMMIT
529
530 from refs/heads/branch^0
531 M 644 inline newdir/interesting
532 data <<EOF
533 $file5_data
534 EOF
535
536 M 755 inline newdir/exec.sh
537 data <<EOF
538 $file6_data
539 EOF
540
541 INPUT_END
542
d67824fe
JS
543 git fast-import <input &&
544 git whatchanged branch
545'
05880b02
JS
546
547test_expect_success 'D: verify pack' '
548 verify_packs
549'
b715cfbb 550
d67824fe 551test_expect_success 'D: validate new files added' '
68297e0f
JS
552 cat >expect <<-EOF &&
553 :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
554 :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
555 EOF
556 git diff-tree -M -r branch^ branch >actual &&
d67824fe
JS
557 compare_diff_raw expect actual
558'
b715cfbb 559
d67824fe 560test_expect_success 'D: verify file5' '
68297e0f 561 echo "$file5_data" >expect &&
d67824fe
JS
562 git cat-file blob branch:newdir/interesting >actual &&
563 test_cmp expect actual
564'
b715cfbb 565
d67824fe 566test_expect_success 'D: verify file6' '
68297e0f 567 echo "$file6_data" >expect &&
d67824fe
JS
568 git cat-file blob branch:newdir/exec.sh >actual &&
569 test_cmp expect actual
570'
b715cfbb 571
63e0c8b3
SP
572###
573### series E
574###
575
68297e0f
JS
576test_expect_success 'E: rfc2822 date, --date-format=raw' '
577 cat >input <<-INPUT_END &&
578 commit refs/heads/branch
579 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
580 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
581 data <<COMMIT
582 RFC 2822 type date
583 COMMIT
584
585 from refs/heads/branch^0
63e0c8b3 586
68297e0f 587 INPUT_END
63e0c8b3 588
d67824fe
JS
589 test_must_fail git fast-import --date-format=raw <input
590'
591test_expect_success 'E: rfc2822 date, --date-format=rfc2822' '
592 git fast-import --date-format=rfc2822 <input
41ac414e 593'
05880b02
JS
594
595test_expect_success 'E: verify pack' '
596 verify_packs
597'
63e0c8b3 598
d67824fe 599test_expect_success 'E: verify commit' '
68297e0f
JS
600 cat >expect <<-EOF &&
601 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
602 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
603
604 RFC 2822 type date
605 EOF
d67824fe
JS
606 git cat-file commit branch | sed 1,2d >actual &&
607 test_cmp expect actual
608'
63e0c8b3 609
7073e69e
SP
610###
611### series F
612###
613
68297e0f 614test_expect_success 'F: non-fast-forward update skips' '
80a6b3f0 615 old_branch=$(git rev-parse --verify branch^0) &&
68297e0f
JS
616 test_tick &&
617 cat >input <<-INPUT_END &&
618 commit refs/heads/branch
619 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
620 data <<COMMIT
621 losing things already?
622 COMMIT
7073e69e 623
68297e0f 624 from refs/heads/branch~1
7073e69e 625
68297e0f
JS
626 reset refs/heads/other
627 from refs/heads/branch
628
629 INPUT_END
7073e69e 630
b08d82f0
JS
631 test_must_fail git fast-import <input &&
632 # branch must remain unaffected
80a6b3f0 633 test $old_branch = $(git rev-parse --verify branch^0)
d67824fe 634'
05880b02
JS
635
636test_expect_success 'F: verify pack' '
637 verify_packs
638'
7073e69e 639
d67824fe 640test_expect_success 'F: verify other commit' '
68297e0f 641 cat >expect <<-EOF &&
80a6b3f0
EP
642 tree $(git rev-parse branch~1^{tree})
643 parent $(git rev-parse branch~1)
68297e0f
JS
644 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
645 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
646
647 losing things already?
648 EOF
d67824fe
JS
649 git cat-file commit other >actual &&
650 test_cmp expect actual
651'
7073e69e
SP
652
653###
654### series G
655###
656
68297e0f 657test_expect_success 'G: non-fast-forward update forced' '
80a6b3f0 658 old_branch=$(git rev-parse --verify branch^0) &&
68297e0f
JS
659 test_tick &&
660 cat >input <<-INPUT_END &&
661 commit refs/heads/branch
662 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
663 data <<COMMIT
664 losing things already?
665 COMMIT
7073e69e 666
68297e0f 667 from refs/heads/branch~1
7073e69e 668
68297e0f 669 INPUT_END
d67824fe
JS
670 git fast-import --force <input
671'
05880b02
JS
672
673test_expect_success 'G: verify pack' '
674 verify_packs
675'
676
d67824fe 677test_expect_success 'G: branch changed, but logged' '
80a6b3f0
EP
678 test $old_branch != $(git rev-parse --verify branch^0) &&
679 test $old_branch = $(git rev-parse --verify branch@{1})
d67824fe 680'
7073e69e 681
825769a8
SP
682###
683### series H
684###
685
d67824fe 686test_expect_success 'H: deletall, add 1' '
68297e0f
JS
687 test_tick &&
688 cat >input <<-INPUT_END &&
689 commit refs/heads/H
690 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
691 data <<COMMIT
692 third
693 COMMIT
694
695 from refs/heads/branch^0
696 M 644 inline i-will-die
697 data <<EOF
698 this file will never exist.
699 EOF
700
701 deleteall
702 M 644 inline h/e/l/lo
703 data <<EOF
704 $file5_data
705 EOF
706
707 INPUT_END
d67824fe
JS
708 git fast-import <input &&
709 git whatchanged H
710'
05880b02
JS
711
712test_expect_success 'H: verify pack' '
713 verify_packs
714'
825769a8 715
d67824fe 716test_expect_success 'H: validate old files removed, new files added' '
68297e0f
JS
717 cat >expect <<-EOF &&
718 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
719 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
720 :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
721 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
722 :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
723 EOF
724 git diff-tree -M -r H^ H >actual &&
d67824fe
JS
725 compare_diff_raw expect actual
726'
825769a8 727
d67824fe 728test_expect_success 'H: verify file' '
68297e0f 729 echo "$file5_data" >expect &&
d67824fe
JS
730 git cat-file blob H:h/e/l/lo >actual &&
731 test_cmp expect actual
732'
825769a8 733
bdf1c06d
SP
734###
735### series I
736###
737
68297e0f
JS
738test_expect_success 'I: export-pack-edges' '
739 cat >input <<-INPUT_END &&
740 commit refs/heads/export-boundary
741 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
742 data <<COMMIT
743 we have a border. its only 40 characters wide.
744 COMMIT
bdf1c06d 745
68297e0f 746 from refs/heads/branch
bdf1c06d 747
68297e0f 748 INPUT_END
d67824fe
JS
749 git fast-import --export-pack-edges=edges.list <input
750'
bdf1c06d 751
d67824fe 752test_expect_success 'I: verify edge list' '
68297e0f 753 cat >expect <<-EOF &&
80a6b3f0 754 .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
68297e0f 755 EOF
d67824fe
JS
756 sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
757 test_cmp expect actual
758'
bdf1c06d 759
ea5e370a
SP
760###
761### series J
762###
763
68297e0f
JS
764test_expect_success 'J: reset existing branch creates empty commit' '
765 cat >input <<-INPUT_END &&
766 commit refs/heads/J
767 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
768 data <<COMMIT
769 create J
770 COMMIT
ea5e370a 771
68297e0f 772 from refs/heads/branch
ea5e370a 773
68297e0f 774 reset refs/heads/J
ea5e370a 775
68297e0f
JS
776 commit refs/heads/J
777 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
778 data <<COMMIT
779 initialize J
780 COMMIT
ea5e370a 781
68297e0f 782 INPUT_END
d67824fe
JS
783 git fast-import <input
784'
785test_expect_success 'J: branch has 1 commit, empty tree' '
80a6b3f0
EP
786 test 1 = $(git rev-list J | wc -l) &&
787 test 0 = $(git ls-tree J | wc -l)
d67824fe 788'
ea5e370a 789
d67824fe 790test_expect_success 'J: tag must fail on empty branch' '
68297e0f
JS
791 cat >input <<-INPUT_END &&
792 reset refs/heads/J2
793
794 tag wrong_tag
795 from refs/heads/J2
796 data <<EOF
797 Tag branch that was reset.
798 EOF
799 INPUT_END
d67824fe
JS
800 test_must_fail git fast-import <input
801'
68297e0f 802
ea5e370a
SP
803###
804### series K
805###
806
68297e0f
JS
807test_expect_success 'K: reinit branch with from' '
808 cat >input <<-INPUT_END &&
809 commit refs/heads/K
810 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
811 data <<COMMIT
812 create K
813 COMMIT
ea5e370a 814
68297e0f 815 from refs/heads/branch
ea5e370a 816
68297e0f
JS
817 commit refs/heads/K
818 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
819 data <<COMMIT
820 redo K
821 COMMIT
ea5e370a 822
68297e0f 823 from refs/heads/branch^1
ea5e370a 824
68297e0f 825 INPUT_END
d67824fe
JS
826 git fast-import <input
827'
828test_expect_success 'K: verify K^1 = branch^1' '
80a6b3f0
EP
829 test $(git rev-parse --verify branch^1) \
830 = $(git rev-parse --verify K^1)
d67824fe 831'
ea5e370a 832
e7411303
JK
833###
834### series L
835###
836
68297e0f
JS
837test_expect_success 'L: verify internal tree sorting' '
838 cat >input <<-INPUT_END &&
839 blob
840 mark :1
841 data <<EOF
842 some data
843 EOF
844
845 blob
846 mark :2
847 data <<EOF
848 other data
849 EOF
850
851 commit refs/heads/L
852 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
853 data <<COMMIT
854 create L
855 COMMIT
856
857 M 644 :1 b.
858 M 644 :1 b/other
859 M 644 :1 ba
860
861 commit refs/heads/L
862 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
863 data <<COMMIT
864 update L
865 COMMIT
866
867 M 644 :2 b.
868 M 644 :2 b/other
869 M 644 :2 ba
870 INPUT_END
871
872 cat >expect <<-EXPECT_END &&
873 :100644 100644 4268632... 55d3a52... M b.
874 :040000 040000 0ae5cac... 443c768... M b
875 :100644 100644 4268632... 55d3a52... M ba
876 EXPECT_END
877
878 git fast-import <input &&
879 git diff-tree --abbrev --raw L^ L >output &&
880 test_cmp expect output
881'
882
883test_expect_success 'L: nested tree copy does not corrupt deltas' '
884 cat >input <<-INPUT_END &&
885 blob
886 mark :1
887 data <<EOF
888 the data
889 EOF
890
891 commit refs/heads/L2
892 committer C O Mitter <committer@example.com> 1112912473 -0700
893 data <<COMMIT
894 init L2
895 COMMIT
896 M 644 :1 a/b/c
897 M 644 :1 a/b/d
898 M 644 :1 a/e/f
e7411303 899
68297e0f
JS
900 commit refs/heads/L2
901 committer C O Mitter <committer@example.com> 1112912473 -0700
902 data <<COMMIT
903 update L2
904 COMMIT
905 C a g
906 C a/e g/b
907 M 644 :1 g/b/h
908 INPUT_END
e7411303 909
68297e0f
JS
910 cat >expect <<-\EOF &&
911 g/b/f
912 g/b/h
913 EOF
9a0edb79 914
93e911f5 915 test_when_finished "git update-ref -d refs/heads/L2" &&
d67824fe 916 git fast-import <input &&
9a0edb79
DI
917 git ls-tree L2 g/b/ >tmp &&
918 cat tmp | cut -f 2 >actual &&
919 test_cmp expect actual &&
80a6b3f0 920 git fsck $(git rev-parse L2)
d67824fe 921'
9a0edb79 922
f39a946a
SP
923###
924### series M
925###
926
68297e0f
JS
927test_expect_success 'M: rename file in same subdirectory' '
928 test_tick &&
929 cat >input <<-INPUT_END &&
930 commit refs/heads/M1
931 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
932 data <<COMMIT
933 file rename
934 COMMIT
f39a946a 935
68297e0f
JS
936 from refs/heads/branch^0
937 R file2/newf file2/n.e.w.f
f39a946a 938
68297e0f 939 INPUT_END
f39a946a 940
68297e0f
JS
941 cat >expect <<-EOF &&
942 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
943 EOF
d67824fe
JS
944 git fast-import <input &&
945 git diff-tree -M -r M1^ M1 >actual &&
946 compare_diff_raw expect actual
947'
f39a946a 948
68297e0f
JS
949test_expect_success 'M: rename file to new subdirectory' '
950 cat >input <<-INPUT_END &&
951 commit refs/heads/M2
952 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
953 data <<COMMIT
954 file rename
955 COMMIT
f39a946a 956
68297e0f
JS
957 from refs/heads/branch^0
958 R file2/newf i/am/new/to/you
f39a946a 959
68297e0f 960 INPUT_END
f39a946a 961
68297e0f
JS
962 cat >expect <<-EOF &&
963 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
964 EOF
d67824fe
JS
965 git fast-import <input &&
966 git diff-tree -M -r M2^ M2 >actual &&
967 compare_diff_raw expect actual
968'
f39a946a 969
68297e0f
JS
970test_expect_success 'M: rename subdirectory to new subdirectory' '
971 cat >input <<-INPUT_END &&
972 commit refs/heads/M3
973 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
974 data <<COMMIT
975 file rename
976 COMMIT
f39a946a 977
68297e0f
JS
978 from refs/heads/M2^0
979 R i other/sub
f39a946a 980
68297e0f 981 INPUT_END
f39a946a 982
68297e0f
JS
983 cat >expect <<-EOF &&
984 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
985 EOF
d67824fe
JS
986 git fast-import <input &&
987 git diff-tree -M -r M3^ M3 >actual &&
988 compare_diff_raw expect actual
989'
f39a946a 990
68297e0f
JS
991test_expect_success 'M: rename root to subdirectory' '
992 cat >input <<-INPUT_END &&
993 commit refs/heads/M4
994 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
995 data <<COMMIT
996 rename root
997 COMMIT
aca70610 998
68297e0f
JS
999 from refs/heads/M2^0
1000 R "" sub
aca70610 1001
68297e0f 1002 INPUT_END
aca70610 1003
68297e0f
JS
1004 cat >expect <<-EOF &&
1005 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1006 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1007 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1008 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1009 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1010 EOF
d67824fe
JS
1011 git fast-import <input &&
1012 git diff-tree -M -r M4^ M4 >actual &&
1013 cat actual &&
1014 compare_diff_raw expect actual
1015'
aca70610 1016
b6f3481b
SP
1017###
1018### series N
1019###
1020
68297e0f
JS
1021test_expect_success 'N: copy file in same subdirectory' '
1022 test_tick &&
1023 cat >input <<-INPUT_END &&
1024 commit refs/heads/N1
1025 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1026 data <<COMMIT
1027 file copy
1028 COMMIT
b6f3481b 1029
68297e0f
JS
1030 from refs/heads/branch^0
1031 C file2/newf file2/n.e.w.f
b6f3481b 1032
68297e0f 1033 INPUT_END
b6f3481b 1034
68297e0f
JS
1035 cat >expect <<-EOF &&
1036 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
1037 EOF
d67824fe
JS
1038 git fast-import <input &&
1039 git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
1040 compare_diff_raw expect actual
1041'
b6f3481b 1042
68297e0f
JS
1043test_expect_success 'N: copy then modify subdirectory' '
1044 cat >input <<-INPUT_END &&
1045 commit refs/heads/N2
1046 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1047 data <<COMMIT
1048 clean directory copy
1049 COMMIT
b6f3481b 1050
68297e0f
JS
1051 from refs/heads/branch^0
1052 C file2 file3
b6f3481b 1053
68297e0f
JS
1054 commit refs/heads/N2
1055 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1056 data <<COMMIT
1057 modify directory copy
1058 COMMIT
b6f3481b 1059
68297e0f
JS
1060 M 644 inline file3/file5
1061 data <<EOF
1062 $file5_data
1063 EOF
b6f3481b 1064
68297e0f 1065 INPUT_END
b6f3481b 1066
68297e0f
JS
1067 cat >expect <<-EOF &&
1068 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1069 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1070 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1071 EOF
d67824fe
JS
1072 git fast-import <input &&
1073 git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
1074 compare_diff_raw expect actual
1075'
b6f3481b 1076
68297e0f
JS
1077test_expect_success 'N: copy dirty subdirectory' '
1078 cat >input <<-INPUT_END &&
1079 commit refs/heads/N3
1080 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1081 data <<COMMIT
1082 dirty directory copy
1083 COMMIT
b6f3481b 1084
68297e0f
JS
1085 from refs/heads/branch^0
1086 M 644 inline file2/file5
1087 data <<EOF
1088 $file5_data
1089 EOF
b6f3481b 1090
68297e0f
JS
1091 C file2 file3
1092 D file2/file5
b6f3481b 1093
68297e0f 1094 INPUT_END
b6f3481b 1095
d67824fe 1096 git fast-import <input &&
80a6b3f0 1097 test $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})
d67824fe 1098'
b6f3481b 1099
d67824fe
JS
1100test_expect_success 'N: copy directory by id' '
1101 cat >expect <<-\EOF &&
334fba65
JN
1102 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1103 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1104 EOF
d67824fe
JS
1105 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1106 cat >input <<-INPUT_END &&
334fba65
JN
1107 commit refs/heads/N4
1108 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1109 data <<COMMIT
1110 copy by tree hash
1111 COMMIT
1112
1113 from refs/heads/branch^0
1114 M 040000 $subdir file3
1115 INPUT_END
d67824fe
JS
1116 git fast-import <input &&
1117 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1118 compare_diff_raw expect actual
1119'
334fba65 1120
8dc6a373 1121test_expect_success PIPE 'N: read and copy directory' '
99094a7a 1122 cat >expect <<-\EOF &&
8dc6a373
DB
1123 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1124 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1125 EOF
1126 git update-ref -d refs/heads/N4 &&
1127 rm -f backflow &&
1128 mkfifo backflow &&
1129 (
1130 exec <backflow &&
1131 cat <<-EOF &&
1132 commit refs/heads/N4
1133 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1134 data <<COMMIT
1135 copy by tree hash, part 2
1136 COMMIT
1137
1138 from refs/heads/branch^0
1139 ls "file2"
1140 EOF
1141 read mode type tree filename &&
1142 echo "M 040000 $tree file3"
1143 ) |
1144 git fast-import --cat-blob-fd=3 3>backflow &&
1145 git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
1146 compare_diff_raw expect actual
1147'
1148
1149test_expect_success PIPE 'N: empty directory reads as missing' '
1150 cat <<-\EOF >expect &&
1151 OBJNAME
1152 :000000 100644 OBJNAME OBJNAME A unrelated
1153 EOF
1154 echo "missing src" >expect.response &&
1155 git update-ref -d refs/heads/read-empty &&
1156 rm -f backflow &&
1157 mkfifo backflow &&
1158 (
1159 exec <backflow &&
1160 cat <<-EOF &&
1161 commit refs/heads/read-empty
1162 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1163 data <<COMMIT
1164 read "empty" (missing) directory
1165 COMMIT
1166
1167 M 100644 inline src/greeting
1168 data <<BLOB
1169 hello
1170 BLOB
1171 C src/greeting dst1/non-greeting
1172 C src/greeting unrelated
1173 # leave behind "empty" src directory
1174 D src/greeting
1175 ls "src"
1176 EOF
1177 read -r line &&
1178 printf "%s\n" "$line" >response &&
1179 cat <<-\EOF
1180 D dst1
1181 D dst2
1182 EOF
1183 ) |
1184 git fast-import --cat-blob-fd=3 3>backflow &&
1185 test_cmp expect.response response &&
1186 git rev-list read-empty |
1187 git diff-tree -r --root --stdin |
1188 sed "s/$_x40/OBJNAME/g" >actual &&
1189 test_cmp expect actual
1190'
1191
d67824fe
JS
1192test_expect_success 'N: copy root directory by tree hash' '
1193 cat >expect <<-\EOF &&
2794ad52
DB
1194 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
1195 :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
1196 EOF
d67824fe
JS
1197 root=$(git rev-parse refs/heads/branch^0^{tree}) &&
1198 cat >input <<-INPUT_END &&
2794ad52
DB
1199 commit refs/heads/N6
1200 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1201 data <<COMMIT
1202 copy root directory by tree hash
1203 COMMIT
1204
1205 from refs/heads/branch^0
1206 M 040000 $root ""
1207 INPUT_END
d67824fe
JS
1208 git fast-import <input &&
1209 git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
1210 compare_diff_raw expect actual
1211'
2794ad52 1212
d67824fe
JS
1213test_expect_success 'N: copy root by path' '
1214 cat >expect <<-\EOF &&
aca70610
JK
1215 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1216 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1217 :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1218 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1219 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1220 EOF
d67824fe 1221 cat >input <<-INPUT_END &&
aca70610
JK
1222 commit refs/heads/N-copy-root-path
1223 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1224 data <<COMMIT
1225 copy root directory by (empty) path
1226 COMMIT
1227
1228 from refs/heads/branch^0
1229 C "" oldroot
1230 INPUT_END
d67824fe
JS
1231 git fast-import <input &&
1232 git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1233 compare_diff_raw expect actual
1234'
aca70610 1235
d67824fe
JS
1236test_expect_success 'N: delete directory by copying' '
1237 cat >expect <<-\EOF &&
8fe533f6
JN
1238 OBJID
1239 :100644 000000 OBJID OBJID D foo/bar/qux
1240 OBJID
1241 :000000 100644 OBJID OBJID A foo/bar/baz
1242 :000000 100644 OBJID OBJID A foo/bar/qux
1243 EOF
d67824fe
JS
1244 empty_tree=$(git mktree </dev/null) &&
1245 cat >input <<-INPUT_END &&
8fe533f6
JN
1246 commit refs/heads/N-delete
1247 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1248 data <<COMMIT
1249 collect data to be deleted
1250 COMMIT
1251
1252 deleteall
1253 M 100644 inline foo/bar/baz
1254 data <<DATA_END
1255 hello
1256 DATA_END
1257 C "foo/bar/baz" "foo/bar/qux"
1258 C "foo/bar/baz" "foo/bar/quux/1"
1259 C "foo/bar/baz" "foo/bar/quuux"
1260 M 040000 $empty_tree foo/bar/quux
1261 M 040000 $empty_tree foo/bar/quuux
1262
1263 commit refs/heads/N-delete
1264 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1265 data <<COMMIT
1266 delete subdirectory
1267 COMMIT
1268
1269 M 040000 $empty_tree foo/bar/qux
1270 INPUT_END
d67824fe
JS
1271 git fast-import <input &&
1272 git rev-list N-delete |
8fe533f6
JN
1273 git diff-tree -r --stdin --root --always |
1274 sed -e "s/$_x40/OBJID/g" >actual &&
d67824fe
JS
1275 test_cmp expect actual
1276'
8fe533f6 1277
d67824fe
JS
1278test_expect_success 'N: modify copied tree' '
1279 cat >expect <<-\EOF &&
334fba65
JN
1280 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
1281 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
1282 :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
1283 EOF
d67824fe
JS
1284 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1285 cat >input <<-INPUT_END &&
334fba65
JN
1286 commit refs/heads/N5
1287 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1288 data <<COMMIT
1289 copy by tree hash
1290 COMMIT
1291
1292 from refs/heads/branch^0
1293 M 040000 $subdir file3
1294
1295 commit refs/heads/N5
1296 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1297 data <<COMMIT
1298 modify directory copy
1299 COMMIT
1300
1301 M 644 inline file3/file5
1302 data <<EOF
1303 $file5_data
1304 EOF
1305 INPUT_END
d67824fe
JS
1306 git fast-import <input &&
1307 git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
1308 compare_diff_raw expect actual
1309'
1310
1311test_expect_success 'N: reject foo/ syntax' '
1312 subdir=$(git rev-parse refs/heads/branch^0:file2) &&
1313 test_must_fail git fast-import <<-INPUT_END
34215783
JN
1314 commit refs/heads/N5B
1315 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1316 data <<COMMIT
1317 copy with invalid syntax
1318 COMMIT
1319
1320 from refs/heads/branch^0
1321 M 040000 $subdir file3/
d67824fe
JS
1322 INPUT_END
1323'
34215783 1324
d67824fe
JS
1325test_expect_success 'N: reject foo/ syntax in copy source' '
1326 test_must_fail git fast-import <<-INPUT_END
178e1dea
JN
1327 commit refs/heads/N5C
1328 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1329 data <<COMMIT
1330 copy with invalid syntax
1331 COMMIT
1332
1333 from refs/heads/branch^0
1334 C file2/ file3
d67824fe
JS
1335 INPUT_END
1336'
178e1dea 1337
d67824fe
JS
1338test_expect_success 'N: reject foo/ syntax in rename source' '
1339 test_must_fail git fast-import <<-INPUT_END
178e1dea
JN
1340 commit refs/heads/N5D
1341 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1342 data <<COMMIT
1343 rename with invalid syntax
1344 COMMIT
1345
1346 from refs/heads/branch^0
1347 R file2/ file3
d67824fe
JS
1348 INPUT_END
1349'
178e1dea 1350
d67824fe
JS
1351test_expect_success 'N: reject foo/ syntax in ls argument' '
1352 test_must_fail git fast-import <<-INPUT_END
178e1dea
JN
1353 commit refs/heads/N5E
1354 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1355 data <<COMMIT
1356 copy with invalid syntax
1357 COMMIT
1358
1359 from refs/heads/branch^0
1360 ls "file2/"
d67824fe
JS
1361 INPUT_END
1362'
178e1dea 1363
d67824fe
JS
1364test_expect_success 'N: copy to root by id and modify' '
1365 echo "hello, world" >expect.foo &&
1366 echo hello >expect.bar &&
1367 git fast-import <<-SETUP_END &&
5edde510
JN
1368 commit refs/heads/N7
1369 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1370 data <<COMMIT
1371 hello, tree
1372 COMMIT
1373
1374 deleteall
1375 M 644 inline foo/bar
1376 data <<EOF
1377 hello
1378 EOF
1379 SETUP_END
1380
d67824fe
JS
1381 tree=$(git rev-parse --verify N7:) &&
1382 git fast-import <<-INPUT_END &&
5edde510
JN
1383 commit refs/heads/N8
1384 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1385 data <<COMMIT
1386 copy to root by id and modify
1387 COMMIT
1388
1389 M 040000 $tree ""
1390 M 644 inline foo/foo
1391 data <<EOF
1392 hello, world
1393 EOF
1394 INPUT_END
d67824fe
JS
1395 git show N8:foo/foo >actual.foo &&
1396 git show N8:foo/bar >actual.bar &&
1397 test_cmp expect.foo actual.foo &&
1398 test_cmp expect.bar actual.bar
1399'
1400
1401test_expect_success 'N: extract subtree' '
1402 branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
1403 cat >input <<-INPUT_END &&
34215783
JN
1404 commit refs/heads/N9
1405 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1406 data <<COMMIT
1407 extract subtree branch:newdir
1408 COMMIT
1409
1410 M 040000 $branch ""
971728c8 1411 C "newdir" ""
34215783 1412 INPUT_END
d67824fe
JS
1413 git fast-import <input &&
1414 git diff --exit-code branch:newdir N9
1415'
1416
1417test_expect_success 'N: modify subtree, extract it, and modify again' '
1418 echo hello >expect.baz &&
1419 echo hello, world >expect.qux &&
1420 git fast-import <<-SETUP_END &&
971728c8
JN
1421 commit refs/heads/N10
1422 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1423 data <<COMMIT
1424 hello, tree
1425 COMMIT
1426
1427 deleteall
1428 M 644 inline foo/bar/baz
1429 data <<EOF
1430 hello
1431 EOF
1432 SETUP_END
1433
d67824fe
JS
1434 tree=$(git rev-parse --verify N10:) &&
1435 git fast-import <<-INPUT_END &&
971728c8
JN
1436 commit refs/heads/N11
1437 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1438 data <<COMMIT
1439 copy to root by id and modify
1440 COMMIT
1441
1442 M 040000 $tree ""
1443 M 100644 inline foo/bar/qux
1444 data <<EOF
1445 hello, world
1446 EOF
1447 R "foo" ""
1448 C "bar/qux" "bar/quux"
1449 INPUT_END
d67824fe
JS
1450 git show N11:bar/baz >actual.baz &&
1451 git show N11:bar/qux >actual.qux &&
1452 git show N11:bar/quux >actual.quux &&
1453 test_cmp expect.baz actual.baz &&
1454 test_cmp expect.qux actual.qux &&
1455 test_cmp expect.qux actual.quux'
971728c8 1456
401d53fa
SP
1457###
1458### series O
1459###
1460
68297e0f
JS
1461test_expect_success 'O: comments are all skipped' '
1462 cat >input <<-INPUT_END &&
1463 #we will
1464 commit refs/heads/O1
1465 # -- ignore all of this text
1466 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1467 # $GIT_COMMITTER_NAME has inserted here for his benefit.
1468 data <<COMMIT
1469 dirty directory copy
1470 COMMIT
1471
1472 # do not forget the import blank line!
1473 #
1474 # yes, we started from our usual base of branch^0.
1475 # i like branch^0.
1476 from refs/heads/branch^0
1477 # and we need to reuse file2/file5 from N3 above.
1478 M 644 inline file2/file5
1479 # otherwise the tree will be different
1480 data <<EOF
1481 $file5_data
1482 EOF
401d53fa 1483
68297e0f
JS
1484 # do not forget to copy file2 to file3
1485 C file2 file3
1486 #
1487 # or to delete file5 from file2.
1488 D file2/file5
1489 # are we done yet?
1490
1491 INPUT_END
401d53fa 1492
d67824fe 1493 git fast-import <input &&
80a6b3f0 1494 test $(git rev-parse N3) = $(git rev-parse O1)
d67824fe 1495'
401d53fa 1496
68297e0f
JS
1497test_expect_success 'O: blank lines not necessary after data commands' '
1498 cat >input <<-INPUT_END &&
1499 commit refs/heads/O2
1500 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1501 data <<COMMIT
1502 dirty directory copy
1503 COMMIT
1504 from refs/heads/branch^0
1505 M 644 inline file2/file5
1506 data <<EOF
1507 $file5_data
1508 EOF
1509 C file2 file3
1510 D file2/file5
2c570cde 1511
68297e0f 1512 INPUT_END
2c570cde 1513
d67824fe 1514 git fast-import <input &&
80a6b3f0 1515 test $(git rev-parse N3) = $(git rev-parse O2)
d67824fe 1516'
2c570cde 1517
d67824fe
JS
1518test_expect_success 'O: repack before next test' '
1519 git repack -a -d
1520'
1fdb649c 1521
d67824fe 1522test_expect_success 'O: blank lines not necessary after other commands' '
68297e0f
JS
1523 cat >input <<-INPUT_END &&
1524 commit refs/heads/O3
1525 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1526 data <<COMMIT
1527 zstring
1528 COMMIT
1529 commit refs/heads/O3
1530 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1531 data <<COMMIT
1532 zof
1533 COMMIT
1534 checkpoint
1535 commit refs/heads/O3
1536 mark :5
1537 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1538 data <<COMMIT
1539 zempty
1540 COMMIT
1541 checkpoint
1542 commit refs/heads/O3
1543 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1544 data <<COMMIT
1545 zcommits
1546 COMMIT
1547 reset refs/tags/O3-2nd
1548 from :5
1549 reset refs/tags/O3-3rd
1550 from :5
1551 INPUT_END
1552
1553 cat >expect <<-INPUT_END &&
1554 string
1555 of
1556 empty
1557 commits
1558 INPUT_END
1559
d67824fe 1560 git fast-import <input &&
80a6b3f0
EP
1561 test 8 = $(find .git/objects/pack -type f | wc -l) &&
1562 test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
d67824fe
JS
1563 git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
1564 test_cmp expect actual
1565'
1fdb649c 1566
d67824fe 1567test_expect_success 'O: progress outputs as requested by input' '
68297e0f
JS
1568 cat >input <<-INPUT_END &&
1569 commit refs/heads/O4
1570 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1571 data <<COMMIT
1572 zstring
1573 COMMIT
1574 commit refs/heads/O4
1575 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1576 data <<COMMIT
1577 zof
1578 COMMIT
1579 progress Two commits down, 2 to go!
1580 commit refs/heads/O4
1581 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1582 data <<COMMIT
1583 zempty
1584 COMMIT
1585 progress Three commits down, 1 to go!
1586 commit refs/heads/O4
1587 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1588 data <<COMMIT
1589 zcommits
1590 COMMIT
1591 progress done!
1592 INPUT_END
d67824fe
JS
1593 git fast-import <input >actual &&
1594 grep "progress " <input >expect &&
1595 test_cmp expect actual
1596'
ac053c02 1597
68297e0f
JS
1598###
1599### series P (gitlinks)
1600###
1601
1602test_expect_success 'P: superproject & submodule mix' '
1603 cat >input <<-INPUT_END &&
1604 blob
1605 mark :1
1606 data 10
1607 test file
1608
1609 reset refs/heads/sub
1610 commit refs/heads/sub
1611 mark :2
1612 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1613 data 12
1614 sub_initial
1615 M 100644 :1 file
1616
1617 blob
1618 mark :3
1619 data <<DATAEND
1620 [submodule "sub"]
1621 path = sub
80a6b3f0 1622 url = "$(pwd)/sub"
68297e0f
JS
1623 DATAEND
1624
1625 commit refs/heads/subuse1
1626 mark :4
1627 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1628 data 8
1629 initial
1630 from refs/heads/master
1631 M 100644 :3 .gitmodules
1632 M 160000 :2 sub
1633
1634 blob
1635 mark :5
1636 data 20
1637 test file
1638 more data
1639
1640 commit refs/heads/sub
1641 mark :6
1642 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1643 data 11
1644 sub_second
1645 from :2
1646 M 100644 :5 file
1647
1648 commit refs/heads/subuse1
1649 mark :7
1650 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1651 data 7
1652 second
1653 from :4
1654 M 160000 :6 sub
1655
1656 INPUT_END
1657
1658 git fast-import <input &&
1659 git checkout subuse1 &&
1660 rm -rf sub &&
1661 mkdir sub &&
1662 (
1663 cd sub &&
1664 git init &&
1665 git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
1666 git checkout master
1667 ) &&
1668 git submodule init &&
1669 git submodule update
1670'
1671
1672test_expect_success 'P: verbatim SHA gitlinks' '
1673 SUBLAST=$(git rev-parse --verify sub) &&
1674 SUBPREV=$(git rev-parse --verify sub^) &&
1675
1676 cat >input <<-INPUT_END &&
1677 blob
1678 mark :1
1679 data <<DATAEND
1680 [submodule "sub"]
1681 path = sub
80a6b3f0 1682 url = "$(pwd)/sub"
68297e0f
JS
1683 DATAEND
1684
1685 commit refs/heads/subuse2
1686 mark :2
1687 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1688 data 8
1689 initial
1690 from refs/heads/master
1691 M 100644 :1 .gitmodules
1692 M 160000 $SUBPREV sub
1693
1694 commit refs/heads/subuse2
1695 mark :3
1696 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1697 data 7
1698 second
1699 from :2
1700 M 160000 $SUBLAST sub
1701
1702 INPUT_END
1703
1704 git branch -D sub &&
1705 git gc &&
1706 git prune &&
1707 git fast-import <input &&
1708 test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)
1709'
1710
1711test_expect_success 'P: fail on inline gitlink' '
1712 test_tick &&
1713 cat >input <<-INPUT_END &&
1714 commit refs/heads/subuse3
1715 mark :1
1716 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1717 data <<COMMIT
1718 corrupt
1719 COMMIT
1720
1721 from refs/heads/subuse2
1722 M 160000 inline sub
1723 data <<DATA
1724 $SUBPREV
1725 DATA
1726
1727 INPUT_END
1728
1729 test_must_fail git fast-import <input
1730'
1731
1732test_expect_success 'P: fail on blob mark in gitlink' '
1733 test_tick &&
1734 cat >input <<-INPUT_END &&
1735 blob
1736 mark :1
1737 data <<DATA
1738 $SUBPREV
1739 DATA
1740
1741 commit refs/heads/subuse3
1742 mark :2
1743 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1744 data <<COMMIT
1745 corrupt
1746 COMMIT
1747
1748 from refs/heads/subuse2
1749 M 160000 :1 sub
1750
1751 INPUT_END
1752
1753 test_must_fail git fast-import <input
1754'
1755
1756###
1757### series Q (notes)
1758###
1759
1760test_expect_success 'Q: commit notes' '
1761 note1_data="The first note for the first commit" &&
1762 note2_data="The first note for the second commit" &&
1763 note3_data="The first note for the third commit" &&
1764 note1b_data="The second note for the first commit" &&
1765 note1c_data="The third note for the first commit" &&
1766 note2b_data="The second note for the second commit" &&
1767
1768 test_tick &&
1769 cat >input <<-INPUT_END &&
1770 blob
1771 mark :2
1772 data <<EOF
1773 $file2_data
1774 EOF
1775
1776 commit refs/heads/notes-test
1777 mark :3
1778 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1779 data <<COMMIT
1780 first (:3)
1781 COMMIT
1782
1783 M 644 :2 file2
03db4525 1784
68297e0f
JS
1785 blob
1786 mark :4
1787 data $file4_len
1788 $file4_data
1789 commit refs/heads/notes-test
1790 mark :5
1791 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1792 data <<COMMIT
1793 second (:5)
1794 COMMIT
03db4525 1795
68297e0f 1796 M 644 :4 file4
03db4525 1797
68297e0f
JS
1798 commit refs/heads/notes-test
1799 mark :6
1800 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1801 data <<COMMIT
1802 third (:6)
1803 COMMIT
03db4525 1804
68297e0f
JS
1805 M 644 inline file5
1806 data <<EOF
1807 $file5_data
1808 EOF
03db4525 1809
68297e0f
JS
1810 M 755 inline file6
1811 data <<EOF
1812 $file6_data
1813 EOF
03db4525 1814
68297e0f
JS
1815 blob
1816 mark :7
1817 data <<EOF
1818 $note1_data
1819 EOF
03db4525 1820
68297e0f
JS
1821 blob
1822 mark :8
1823 data <<EOF
1824 $note2_data
1825 EOF
03db4525 1826
68297e0f
JS
1827 commit refs/notes/foobar
1828 mark :9
1829 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1830 data <<COMMIT
1831 notes (:9)
1832 COMMIT
03db4525 1833
68297e0f
JS
1834 N :7 :3
1835 N :8 :5
1836 N inline :6
1837 data <<EOF
1838 $note3_data
1839 EOF
03db4525 1840
68297e0f
JS
1841 commit refs/notes/foobar
1842 mark :10
1843 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1844 data <<COMMIT
1845 notes (:10)
1846 COMMIT
03db4525 1847
68297e0f
JS
1848 N inline :3
1849 data <<EOF
1850 $note1b_data
1851 EOF
03db4525 1852
68297e0f
JS
1853 commit refs/notes/foobar2
1854 mark :11
1855 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1856 data <<COMMIT
1857 notes (:11)
1858 COMMIT
03db4525 1859
68297e0f
JS
1860 N inline :3
1861 data <<EOF
1862 $note1c_data
1863 EOF
03db4525 1864
68297e0f
JS
1865 commit refs/notes/foobar
1866 mark :12
1867 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1868 data <<COMMIT
1869 notes (:12)
1870 COMMIT
1871
1872 deleteall
1873 N inline :5
1874 data <<EOF
1875 $note2b_data
1876 EOF
a8dd2e7d 1877
68297e0f 1878 INPUT_END
2a113aee 1879
d67824fe
JS
1880 git fast-import <input &&
1881 git whatchanged notes-test
1882'
05880b02
JS
1883
1884test_expect_success 'Q: verify pack' '
1885 verify_packs
1886'
a8dd2e7d 1887
68297e0f
JS
1888test_expect_success 'Q: verify first commit' '
1889 commit1=$(git rev-parse notes-test~2) &&
1890 commit2=$(git rev-parse notes-test^) &&
1891 commit3=$(git rev-parse notes-test) &&
a8dd2e7d 1892
68297e0f
JS
1893 cat >expect <<-EOF &&
1894 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1895 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
a8dd2e7d 1896
68297e0f
JS
1897 first (:3)
1898 EOF
d67824fe
JS
1899 git cat-file commit notes-test~2 | sed 1d >actual &&
1900 test_cmp expect actual
1901'
a8dd2e7d 1902
d67824fe 1903test_expect_success 'Q: verify second commit' '
68297e0f
JS
1904 cat >expect <<-EOF &&
1905 parent $commit1
1906 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1907 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1908
1909 second (:5)
1910 EOF
d67824fe
JS
1911 git cat-file commit notes-test^ | sed 1d >actual &&
1912 test_cmp expect actual
1913'
a8dd2e7d 1914
d67824fe 1915test_expect_success 'Q: verify third commit' '
68297e0f
JS
1916 cat >expect <<-EOF &&
1917 parent $commit2
1918 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1919 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1920
1921 third (:6)
1922 EOF
d67824fe
JS
1923 git cat-file commit notes-test | sed 1d >actual &&
1924 test_cmp expect actual
1925'
a8dd2e7d 1926
d67824fe 1927test_expect_success 'Q: verify first notes commit' '
68297e0f
JS
1928 cat >expect <<-EOF &&
1929 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1930 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1931
1932 notes (:9)
1933 EOF
d67824fe
JS
1934 git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
1935 test_cmp expect actual
1936'
a8dd2e7d 1937
d67824fe 1938test_expect_success 'Q: verify first notes tree' '
68297e0f
JS
1939 cat >expect.unsorted <<-EOF &&
1940 100644 blob $commit1
1941 100644 blob $commit2
1942 100644 blob $commit3
1943 EOF
1944 cat expect.unsorted | sort >expect &&
d67824fe
JS
1945 git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1946 test_cmp expect actual
1947'
a8dd2e7d 1948
d67824fe 1949test_expect_success 'Q: verify first note for first commit' '
68297e0f 1950 echo "$note1_data" >expect &&
ec2c10be
JS
1951 git cat-file blob refs/notes/foobar~2:$commit1 >actual &&
1952 test_cmp expect actual
d67824fe 1953'
a8dd2e7d 1954
d67824fe 1955test_expect_success 'Q: verify first note for second commit' '
68297e0f 1956 echo "$note2_data" >expect &&
ec2c10be
JS
1957 git cat-file blob refs/notes/foobar~2:$commit2 >actual &&
1958 test_cmp expect actual
d67824fe 1959'
2a113aee 1960
d67824fe 1961test_expect_success 'Q: verify first note for third commit' '
68297e0f 1962 echo "$note3_data" >expect &&
ec2c10be
JS
1963 git cat-file blob refs/notes/foobar~2:$commit3 >actual &&
1964 test_cmp expect actual
d67824fe 1965'
2a113aee 1966
d67824fe 1967test_expect_success 'Q: verify second notes commit' '
68297e0f 1968 cat >expect <<-EOF &&
80a6b3f0 1969 parent $(git rev-parse --verify refs/notes/foobar~2)
68297e0f
JS
1970 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1971 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1972
1973 notes (:10)
1974 EOF
d67824fe
JS
1975 git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
1976 test_cmp expect actual
1977'
2a113aee 1978
d67824fe 1979test_expect_success 'Q: verify second notes tree' '
68297e0f
JS
1980 cat >expect.unsorted <<-EOF &&
1981 100644 blob $commit1
1982 100644 blob $commit2
1983 100644 blob $commit3
1984 EOF
1985 cat expect.unsorted | sort >expect &&
d67824fe
JS
1986 git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
1987 test_cmp expect actual
1988'
2a113aee 1989
d67824fe 1990test_expect_success 'Q: verify second note for first commit' '
68297e0f 1991 echo "$note1b_data" >expect &&
ec2c10be
JS
1992 git cat-file blob refs/notes/foobar^:$commit1 >actual &&
1993 test_cmp expect actual
d67824fe 1994'
2a113aee 1995
d67824fe 1996test_expect_success 'Q: verify first note for second commit' '
68297e0f 1997 echo "$note2_data" >expect &&
ec2c10be
JS
1998 git cat-file blob refs/notes/foobar^:$commit2 >actual &&
1999 test_cmp expect actual
d67824fe 2000'
a8dd2e7d 2001
d67824fe 2002test_expect_success 'Q: verify first note for third commit' '
68297e0f 2003 echo "$note3_data" >expect &&
ec2c10be
JS
2004 git cat-file blob refs/notes/foobar^:$commit3 >actual &&
2005 test_cmp expect actual
d67824fe 2006'
2a113aee 2007
d67824fe 2008test_expect_success 'Q: verify third notes commit' '
68297e0f
JS
2009 cat >expect <<-EOF &&
2010 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2011 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2012
2013 notes (:11)
2014 EOF
d67824fe
JS
2015 git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
2016 test_cmp expect actual
2017'
2a113aee 2018
d67824fe 2019test_expect_success 'Q: verify third notes tree' '
68297e0f
JS
2020 cat >expect.unsorted <<-EOF &&
2021 100644 blob $commit1
2022 EOF
2023 cat expect.unsorted | sort >expect &&
d67824fe
JS
2024 git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2025 test_cmp expect actual
2026'
2a113aee 2027
d67824fe 2028test_expect_success 'Q: verify third note for first commit' '
68297e0f 2029 echo "$note1c_data" >expect &&
ec2c10be
JS
2030 git cat-file blob refs/notes/foobar2:$commit1 >actual &&
2031 test_cmp expect actual
d67824fe 2032'
2a113aee 2033
d67824fe 2034test_expect_success 'Q: verify fourth notes commit' '
68297e0f 2035 cat >expect <<-EOF &&
80a6b3f0 2036 parent $(git rev-parse --verify refs/notes/foobar^)
68297e0f
JS
2037 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2038 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2039
2040 notes (:12)
2041 EOF
d67824fe
JS
2042 git cat-file commit refs/notes/foobar | sed 1d >actual &&
2043 test_cmp expect actual
2044'
2a113aee 2045
d67824fe 2046test_expect_success 'Q: verify fourth notes tree' '
68297e0f
JS
2047 cat >expect.unsorted <<-EOF &&
2048 100644 blob $commit2
2049 EOF
2050 cat expect.unsorted | sort >expect &&
d67824fe
JS
2051 git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
2052 test_cmp expect actual
2053'
2a113aee 2054
d67824fe 2055test_expect_success 'Q: verify second note for second commit' '
68297e0f 2056 echo "$note2b_data" >expect &&
ec2c10be
JS
2057 git cat-file blob refs/notes/foobar:$commit2 >actual &&
2058 test_cmp expect actual
d67824fe 2059'
a8dd2e7d 2060
68297e0f
JS
2061test_expect_success 'Q: deny note on empty branch' '
2062 cat >input <<-EOF &&
2063 reset refs/heads/Q0
0bc69881 2064
68297e0f
JS
2065 commit refs/heads/note-Q0
2066 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2067 data <<COMMIT
2068 Note for an empty branch.
2069 COMMIT
0bc69881 2070
68297e0f
JS
2071 N inline refs/heads/Q0
2072 data <<NOTE
2073 some note
2074 NOTE
2075 EOF
d67824fe
JS
2076 test_must_fail git fast-import <input
2077'
f963bd5d 2078###
2792f26c 2079### series R (feature and option)
f963bd5d
SR
2080###
2081
f963bd5d 2082test_expect_success 'R: abort on unsupported feature' '
68297e0f
JS
2083 cat >input <<-EOF &&
2084 feature no-such-feature-exists
2085 EOF
2086
f963bd5d
SR
2087 test_must_fail git fast-import <input
2088'
2089
f963bd5d 2090test_expect_success 'R: supported feature is accepted' '
68297e0f
JS
2091 cat >input <<-EOF &&
2092 feature date-format=now
2093 EOF
2094
f963bd5d
SR
2095 git fast-import <input
2096'
2097
f963bd5d 2098test_expect_success 'R: abort on receiving feature after data command' '
68297e0f
JS
2099 cat >input <<-EOF &&
2100 blob
2101 data 3
2102 hi
2103 feature date-format=now
2104 EOF
2105
f963bd5d
SR
2106 test_must_fail git fast-import <input
2107'
2108
081751c8 2109test_expect_success 'R: only one import-marks feature allowed per stream' '
816f8067
JK
2110 >git.marks &&
2111 >git2.marks &&
68297e0f
JS
2112 cat >input <<-EOF &&
2113 feature import-marks=git.marks
2114 feature import-marks=git2.marks
2115 EOF
2116
081751c8
SR
2117 test_must_fail git fast-import <input
2118'
2119
68061e34
JK
2120test_expect_success 'R: export-marks feature forbidden by default' '
2121 echo "feature export-marks=git.marks" >input &&
2122 test_must_fail git fast-import <input
2123'
2124
68297e0f
JS
2125test_expect_success 'R: export-marks feature results in a marks file being created' '
2126 cat >input <<-EOF &&
2127 feature export-marks=git.marks
2128 blob
2129 mark :1
2130 data 3
2131 hi
f963bd5d 2132
68297e0f 2133 EOF
f963bd5d 2134
68061e34 2135 git fast-import --allow-unsafe-features <input &&
d67824fe
JS
2136 grep :1 git.marks
2137'
f963bd5d 2138
d67824fe 2139test_expect_success 'R: export-marks options can be overridden by commandline options' '
01968302
JK
2140 cat >input <<-\EOF &&
2141 feature export-marks=feature-sub/git.marks
2142 blob
2143 mark :1
2144 data 3
2145 hi
2146
2147 EOF
68061e34
JK
2148 git fast-import --allow-unsafe-features \
2149 --export-marks=cmdline-sub/other.marks <input &&
01968302
JK
2150 grep :1 cmdline-sub/other.marks &&
2151 test_path_is_missing feature-sub
d67824fe 2152'
f963bd5d 2153
dded4f12
RR
2154test_expect_success 'R: catch typo in marks file name' '
2155 test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
2156 echo "feature import-marks=nonexistent.marks" |
68061e34 2157 test_must_fail git fast-import --allow-unsafe-features
dded4f12
RR
2158'
2159
2160test_expect_success 'R: import and output marks can be the same file' '
2161 rm -f io.marks &&
2162 blob=$(echo hi | git hash-object --stdin) &&
2163 cat >expect <<-EOF &&
2164 :1 $blob
2165 :2 $blob
2166 EOF
2167 git fast-import --export-marks=io.marks <<-\EOF &&
2168 blob
2169 mark :1
2170 data 3
2171 hi
2172
2173 EOF
2174 git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2175 blob
2176 mark :2
2177 data 3
2178 hi
2179
2180 EOF
2181 test_cmp expect io.marks
2182'
2183
2184test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
2185 rm -f io.marks &&
2186 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
2187 blob
2188 mark :1
2189 data 3
2190 hi
2191
2192 EOF
2193'
2194
2195test_expect_success 'R: --import-marks-if-exists' '
2196 rm -f io.marks &&
2197 blob=$(echo hi | git hash-object --stdin) &&
2198 echo ":1 $blob" >expect &&
2199 git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
2200 blob
2201 mark :1
2202 data 3
2203 hi
2204
2205 EOF
2206 test_cmp expect io.marks
2207'
2208
3beb4fc4
DI
2209test_expect_success 'R: feature import-marks-if-exists' '
2210 rm -f io.marks &&
2211 >expect &&
2212
2213 git fast-import --export-marks=io.marks <<-\EOF &&
2214 feature import-marks-if-exists=not_io.marks
2215 EOF
2216 test_cmp expect io.marks &&
2217
2218 blob=$(echo hi | git hash-object --stdin) &&
2219
2220 echo ":1 $blob" >io.marks &&
2221 echo ":1 $blob" >expect &&
2222 echo ":2 $blob" >>expect &&
2223
2224 git fast-import --export-marks=io.marks <<-\EOF &&
2225 feature import-marks-if-exists=io.marks
2226 blob
2227 mark :2
2228 data 3
2229 hi
2230
2231 EOF
2232 test_cmp expect io.marks &&
2233
2234 echo ":3 $blob" >>expect &&
2235
2236 git fast-import --import-marks=io.marks \
2237 --export-marks=io.marks <<-\EOF &&
2238 feature import-marks-if-exists=not_io.marks
2239 blob
2240 mark :3
2241 data 3
2242 hi
2243
2244 EOF
2245 test_cmp expect io.marks &&
2246
2247 >expect &&
2248
2249 git fast-import --import-marks-if-exists=not_io.marks \
8fb26872 2250 --export-marks=io.marks <<-\EOF &&
3beb4fc4
DI
2251 feature import-marks-if-exists=io.marks
2252 EOF
2253 test_cmp expect io.marks
2254'
2255
d67824fe 2256test_expect_success 'R: import to output marks works without any content' '
68297e0f
JS
2257 cat >input <<-EOF &&
2258 feature import-marks=marks.out
2259 feature export-marks=marks.new
2260 EOF
2261
68061e34 2262 git fast-import --allow-unsafe-features <input &&
d67824fe
JS
2263 test_cmp marks.out marks.new
2264'
f963bd5d 2265
d67824fe 2266test_expect_success 'R: import marks prefers commandline marks file over the stream' '
68297e0f
JS
2267 cat >input <<-EOF &&
2268 feature import-marks=nonexistent.marks
2269 feature export-marks=marks.new
2270 EOF
2271
68061e34 2272 git fast-import --import-marks=marks.out --allow-unsafe-features <input &&
d67824fe
JS
2273 test_cmp marks.out marks.new
2274'
f963bd5d 2275
081751c8 2276
081751c8 2277test_expect_success 'R: multiple --import-marks= should be honoured' '
68297e0f
JS
2278 cat >input <<-EOF &&
2279 feature import-marks=nonexistent.marks
2280 feature export-marks=combined.marks
2281 EOF
2282
d67824fe
JS
2283 head -n2 marks.out > one.marks &&
2284 tail -n +3 marks.out > two.marks &&
68061e34
JK
2285 git fast-import --import-marks=one.marks --import-marks=two.marks \
2286 --allow-unsafe-features <input &&
d67824fe 2287 test_cmp marks.out combined.marks
081751c8
SR
2288'
2289
bc3c79ae 2290test_expect_success 'R: feature relative-marks should be honoured' '
68297e0f
JS
2291 cat >input <<-EOF &&
2292 feature relative-marks
2293 feature import-marks=relative.in
2294 feature export-marks=relative.out
2295 EOF
2296
d67824fe
JS
2297 mkdir -p .git/info/fast-import/ &&
2298 cp marks.new .git/info/fast-import/relative.in &&
68061e34 2299 git fast-import --allow-unsafe-features <input &&
d67824fe 2300 test_cmp marks.new .git/info/fast-import/relative.out
bc3c79ae
SR
2301'
2302
bc3c79ae 2303test_expect_success 'R: feature no-relative-marks should be honoured' '
68297e0f
JS
2304 cat >input <<-EOF &&
2305 feature relative-marks
2306 feature import-marks=relative.in
2307 feature no-relative-marks
2308 feature export-marks=non-relative.out
2309 EOF
2310
68061e34 2311 git fast-import --allow-unsafe-features <input &&
d67824fe 2312 test_cmp marks.new non-relative.out
bc3c79ae
SR
2313'
2314
8dc6a373
DB
2315test_expect_success 'R: feature ls supported' '
2316 echo "feature ls" |
2317 git fast-import
2318'
2319
85c62395
DB
2320test_expect_success 'R: feature cat-blob supported' '
2321 echo "feature cat-blob" |
2322 git fast-import
2323'
2324
2325test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
2326 test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
2327'
2328
f57a8715 2329test_expect_success !MINGW 'R: print old blob' '
85c62395
DB
2330 blob=$(echo "yes it can" | git hash-object -w --stdin) &&
2331 cat >expect <<-EOF &&
2332 ${blob} blob 11
2333 yes it can
2334
2335 EOF
2336 echo "cat-blob $blob" |
2337 git fast-import --cat-blob-fd=6 6>actual &&
2338 test_cmp expect actual
2339'
2340
f57a8715 2341test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
85c62395
DB
2342 echo hello >greeting &&
2343 blob=$(git hash-object -w greeting) &&
2344 cat >expect <<-EOF &&
2345 ${blob} blob 6
2346 hello
2347
2348 EOF
2349 git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
2350 cat-blob $blob
2351 EOF
2352 test_cmp expect actual.3 &&
acf3af25 2353 test_must_be_empty actual.1 &&
85c62395
DB
2354 git fast-import 3>actual.3 >actual.1 <<-EOF &&
2355 option cat-blob-fd=3
2356 cat-blob $blob
2357 EOF
acf3af25 2358 test_must_be_empty actual.3 &&
85c62395
DB
2359 test_cmp expect actual.1
2360'
2361
28c7b1f7
MH
2362test_expect_success !MINGW 'R: print mark for new blob' '
2363 echo "effluentish" | git hash-object --stdin >expect &&
2364 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2365 blob
2366 mark :1
2367 data <<BLOB_END
2368 effluentish
2369 BLOB_END
2370 get-mark :1
2371 EOF
2372 test_cmp expect actual
2373'
2374
f57a8715 2375test_expect_success !MINGW 'R: print new blob' '
85c62395
DB
2376 blob=$(echo "yep yep yep" | git hash-object --stdin) &&
2377 cat >expect <<-EOF &&
2378 ${blob} blob 12
2379 yep yep yep
2380
2381 EOF
2382 git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
2383 blob
2384 mark :1
2385 data <<BLOB_END
2386 yep yep yep
2387 BLOB_END
2388 cat-blob :1
2389 EOF
2390 test_cmp expect actual
2391'
2392
f57a8715 2393test_expect_success !MINGW 'R: print new blob by sha1' '
85c62395
DB
2394 blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
2395 cat >expect <<-EOF &&
2396 ${blob} blob 25
2397 a new blob named by sha1
2398
2399 EOF
2400 git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
2401 blob
2402 data <<BLOB_END
2403 a new blob named by sha1
2404 BLOB_END
2405 cat-blob $blob
2406 EOF
2407 test_cmp expect actual
2408'
2409
2410test_expect_success 'setup: big file' '
2411 (
2412 echo "the quick brown fox jumps over the lazy dog" >big &&
2413 for i in 1 2 3
2414 do
2415 cat big big big big >bigger &&
2416 cat bigger bigger bigger bigger >big ||
2417 exit
2418 done
2419 )
2420'
2421
2422test_expect_success 'R: print two blobs to stdout' '
2423 blob1=$(git hash-object big) &&
2424 blob1_len=$(wc -c <big) &&
2425 blob2=$(echo hello | git hash-object --stdin) &&
2426 {
2427 echo ${blob1} blob $blob1_len &&
2428 cat big &&
2429 cat <<-EOF
2430
2431 ${blob2} blob 6
2432 hello
2433
2434 EOF
2435 } >expect &&
2436 {
2437 cat <<-\END_PART1 &&
2438 blob
2439 mark :1
2440 data <<data_end
2441 END_PART1
2442 cat big &&
2443 cat <<-\EOF
2444 data_end
2445 blob
2446 mark :2
2447 data <<data_end
2448 hello
2449 data_end
2450 cat-blob :1
2451 cat-blob :2
2452 EOF
2453 } |
2454 git fast-import >actual &&
2455 test_cmp expect actual
2456'
2457
85c62395
DB
2458test_expect_success PIPE 'R: copy using cat-file' '
2459 expect_id=$(git hash-object big) &&
2460 expect_len=$(wc -c <big) &&
2461 echo $expect_id blob $expect_len >expect.response &&
2462
2463 rm -f blobs &&
2464 cat >frontend <<-\FRONTEND_END &&
2465 #!/bin/sh
85c62395
DB
2466 FRONTEND_END
2467
2468 mkfifo blobs &&
2469 (
2470 export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
4de0bbd8
JN
2471 cat <<-\EOF &&
2472 feature cat-blob
2473 blob
2474 mark :1
2475 data <<BLOB
2476 EOF
2477 cat big &&
2478 cat <<-\EOF &&
2479 BLOB
2480 cat-blob :1
2481 EOF
2482
2483 read blob_id type size <&3 &&
2484 echo "$blob_id $type $size" >response &&
48860819 2485 test_copy_bytes $size >blob <&3 &&
4de0bbd8
JN
2486 read newline <&3 &&
2487
2488 cat <<-EOF &&
2489 commit refs/heads/copied
2490 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2491 data <<COMMIT
2492 copy big file as file3
2493 COMMIT
2494 M 644 inline file3
2495 data <<BLOB
2496 EOF
2497 cat blob &&
2498 echo BLOB
2499 ) 3<blobs |
2500 git fast-import --cat-blob-fd=3 3>blobs &&
85c62395
DB
2501 git show copied:file3 >actual &&
2502 test_cmp expect.response response &&
2503 test_cmp big actual
2504'
2505
777f80d7
JN
2506test_expect_success PIPE 'R: print blob mid-commit' '
2507 rm -f blobs &&
2508 echo "A blob from _before_ the commit." >expect &&
2509 mkfifo blobs &&
2510 (
2511 exec 3<blobs &&
2512 cat <<-EOF &&
2513 feature cat-blob
2514 blob
2515 mark :1
2516 data <<BLOB
2517 A blob from _before_ the commit.
2518 BLOB
2519 commit refs/heads/temporary
2520 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2521 data <<COMMIT
2522 Empty commit
2523 COMMIT
2524 cat-blob :1
2525 EOF
2526
2527 read blob_id type size <&3 &&
48860819 2528 test_copy_bytes $size >actual <&3 &&
777f80d7
JN
2529 read newline <&3 &&
2530
2531 echo
2532 ) |
2533 git fast-import --cat-blob-fd=3 3>blobs &&
2534 test_cmp expect actual
2535'
2536
2537test_expect_success PIPE 'R: print staged blob within commit' '
2538 rm -f blobs &&
2539 echo "A blob from _within_ the commit." >expect &&
2540 mkfifo blobs &&
2541 (
2542 exec 3<blobs &&
2543 cat <<-EOF &&
2544 feature cat-blob
2545 commit refs/heads/within
2546 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2547 data <<COMMIT
2548 Empty commit
2549 COMMIT
2550 M 644 inline within
2551 data <<BLOB
2552 A blob from _within_ the commit.
2553 BLOB
2554 EOF
2555
2556 to_get=$(
2557 echo "A blob from _within_ the commit." |
2558 git hash-object --stdin
2559 ) &&
2560 echo "cat-blob $to_get" &&
2561
2562 read blob_id type size <&3 &&
48860819 2563 test_copy_bytes $size >actual <&3 &&
777f80d7
JN
2564 read newline <&3 &&
2565
2566 echo deleteall
2567 ) |
2568 git fast-import --cat-blob-fd=3 3>blobs &&
2569 test_cmp expect actual
2570'
2571
68297e0f
JS
2572test_expect_success 'R: quiet option results in no stats being output' '
2573 cat >input <<-EOF &&
2574 option git quiet
2575 blob
2576 data 3
2577 hi
2792f26c 2578
68297e0f 2579 EOF
2792f26c 2580
f94804c1 2581 git fast-import 2>output <input &&
acf3af25 2582 test_must_be_empty output
2792f26c
SR
2583'
2584
be56862f
SR
2585test_expect_success 'R: feature done means terminating "done" is mandatory' '
2586 echo feature done | test_must_fail git fast-import &&
2587 test_must_fail git fast-import --done </dev/null
2588'
2589
2590test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
2591 git fast-import <<-\EOF &&
2592 feature done
2593 done
2594 trailing gibberish
2595 EOF
2596 git fast-import <<-\EOF
2597 done
2598 more trailing gibberish
2599 EOF
2600'
2601
2602test_expect_success 'R: terminating "done" within commit' '
2603 cat >expect <<-\EOF &&
2604 OBJID
2605 :000000 100644 OBJID OBJID A hello.c
2606 :000000 100644 OBJID OBJID A hello2.c
2607 EOF
2608 git fast-import <<-EOF &&
2609 commit refs/heads/done-ends
2610 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2611 data <<EOT
2612 Commit terminated by "done" command
2613 EOT
2614 M 100644 inline hello.c
2615 data <<EOT
2616 Hello, world.
2617 EOT
2618 C hello.c hello2.c
2619 done
2620 EOF
2621 git rev-list done-ends |
2622 git diff-tree -r --stdin --root --always |
2623 sed -e "s/$_x40/OBJID/g" >actual &&
2624 test_cmp expect actual
2625'
2626
2792f26c 2627test_expect_success 'R: die on unknown option' '
68297e0f
JS
2628 cat >input <<-EOF &&
2629 option git non-existing-option
2630 EOF
2631
d67824fe 2632 test_must_fail git fast-import <input
2792f26c
SR
2633'
2634
2635test_expect_success 'R: unknown commandline options are rejected' '\
d67824fe 2636 test_must_fail git fast-import --non-existing-option < /dev/null
2792f26c
SR
2637'
2638
a9ff277e
JN
2639test_expect_success 'R: die on invalid option argument' '
2640 echo "option git active-branches=-5" |
2641 test_must_fail git fast-import &&
2642 echo "option git depth=" |
2643 test_must_fail git fast-import &&
2644 test_must_fail git fast-import --depth="5 elephants" </dev/null
2645'
2646
2792f26c 2647test_expect_success 'R: ignore non-git options' '
68297e0f
JS
2648 cat >input <<-EOF &&
2649 option non-existing-vcs non-existing-option
2650 EOF
2651
d67824fe 2652 git fast-import <input
2792f26c
SR
2653'
2654
f4beed60
FC
2655test_expect_success 'R: corrupt lines do not mess marks file' '
2656 rm -f io.marks &&
2657 blob=$(echo hi | git hash-object --stdin) &&
2658 cat >expect <<-EOF &&
2659 :3 0000000000000000000000000000000000000000
2660 :1 $blob
2661 :2 $blob
2662 EOF
2663 cp expect io.marks &&
2664 test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
2665
2666 EOF
2667 test_cmp expect io.marks
2668'
2669
5eef828b
SP
2670##
2671## R: very large blobs
2672##
d67824fe 2673test_expect_success 'R: blob bigger than threshold' '
68297e0f
JS
2674 blobsize=$((2*1024*1024 + 53)) &&
2675 test-genrandom bar $blobsize >expect &&
2676 cat >input <<-INPUT_END &&
2677 commit refs/heads/big-file
2678 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2679 data <<COMMIT
2680 R - big file
2681 COMMIT
2682
2683 M 644 inline big1
2684 data $blobsize
2685 INPUT_END
2686 cat expect >>input &&
2687 cat >>input <<-INPUT_END &&
2688 M 644 inline big2
2689 data $blobsize
2690 INPUT_END
2691 cat expect >>input &&
2692 echo >>input &&
2693
d67824fe 2694 test_create_repo R &&
d9545c7f 2695 git --git-dir=R/.git config fastimport.unpackLimit 0 &&
d67824fe
JS
2696 git --git-dir=R/.git fast-import --big-file-threshold=1 <input
2697'
05880b02
JS
2698
2699test_expect_success 'R: verify created pack' '
2700 (
2701 cd R &&
2702 verify_packs -v > ../verify
2703 )
2704'
2705
d67824fe
JS
2706test_expect_success 'R: verify written objects' '
2707 git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
2708 test_cmp_bin expect actual &&
2709 a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
2710 b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
2711 test $a = $b
2712'
2713
2714test_expect_success 'R: blob appears only once' '
2715 n=$(grep $a verify | wc -l) &&
2716 test 1 = $n
2717'
5eef828b 2718
06454cb9
PW
2719###
2720### series S
2721###
2722#
2723# Make sure missing spaces and EOLs after mark references
2724# cause errors.
2725#
2726# Setup:
2727#
2728# 1--2--4
2729# \ /
2730# -3-
2731#
2732# commit marks: 301, 302, 303, 304
2733# blob marks: 403, 404, resp.
2734# note mark: 202
2735#
2736# The error message when a space is missing not at the
2737# end of the line is:
2738#
2739# Missing space after ..
2740#
2741# or when extra characters come after the mark at the end
2742# of the line:
2743#
2744# Garbage after ..
2745#
2746# or when the dataref is neither "inline " or a known SHA1,
2747#
2748# Invalid dataref ..
2749#
06454cb9 2750test_expect_success 'S: initialize for S tests' '
68297e0f
JS
2751 test_tick &&
2752
2753 cat >input <<-INPUT_END &&
2754 commit refs/heads/S
2755 mark :301
2756 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2757 data <<COMMIT
2758 commit 1
2759 COMMIT
2760 M 100644 inline hello.c
2761 data <<BLOB
2762 blob 1
2763 BLOB
2764
2765 commit refs/heads/S
2766 mark :302
2767 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2768 data <<COMMIT
2769 commit 2
2770 COMMIT
2771 from :301
2772 M 100644 inline hello.c
2773 data <<BLOB
2774 blob 2
2775 BLOB
2776
2777 blob
2778 mark :403
2779 data <<BLOB
2780 blob 3
2781 BLOB
2782
2783 blob
2784 mark :202
2785 data <<BLOB
2786 note 2
2787 BLOB
2788 INPUT_END
2789
06454cb9
PW
2790 git fast-import --export-marks=marks <input
2791'
2792
2793#
2794# filemodify, three datarefs
2795#
2796test_expect_success 'S: filemodify with garbage after mark must fail' '
2797 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2798 commit refs/heads/S
2799 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2800 data <<COMMIT
2801 commit N
2802 COMMIT
2803 M 100644 :403x hello.c
2804 EOF
2805 cat err &&
2806 test_i18ngrep "space after mark" err
2807'
2808
2809# inline is misspelled; fast-import thinks it is some unknown dataref
2810test_expect_success 'S: filemodify with garbage after inline must fail' '
2811 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2812 commit refs/heads/S
2813 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2814 data <<COMMIT
2815 commit N
2816 COMMIT
2817 M 100644 inlineX hello.c
2818 data <<BLOB
2819 inline
2820 BLOB
2821 EOF
2822 cat err &&
2823 test_i18ngrep "nvalid dataref" err
2824'
2825
2826test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2827 sha1=$(grep :403 marks | cut -d\ -f2) &&
2828 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2829 commit refs/heads/S
2830 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2831 data <<COMMIT
2832 commit N
2833 COMMIT
2834 M 100644 ${sha1}x hello.c
2835 EOF
2836 cat err &&
2837 test_i18ngrep "space after SHA1" err
2838'
2839
2840#
2841# notemodify, three ways to say dataref
2842#
64127575 2843test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
06454cb9
PW
2844 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2845 commit refs/heads/S
2846 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2847 data <<COMMIT
2848 commit S note dataref markref
2849 COMMIT
2850 N :202x :302
2851 EOF
2852 cat err &&
2853 test_i18ngrep "space after mark" err
2854'
2855
2856test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
2857 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2858 commit refs/heads/S
2859 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2860 data <<COMMIT
2861 commit S note dataref inline
2862 COMMIT
2863 N inlineX :302
2864 data <<BLOB
2865 note blob
2866 BLOB
2867 EOF
2868 cat err &&
2869 test_i18ngrep "nvalid dataref" err
2870'
2871
2872test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2873 sha1=$(grep :202 marks | cut -d\ -f2) &&
2874 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2875 commit refs/heads/S
2876 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2877 data <<COMMIT
2878 commit S note dataref sha1
2879 COMMIT
2880 N ${sha1}x :302
2881 EOF
2882 cat err &&
2883 test_i18ngrep "space after SHA1" err
2884'
2885
2886#
a8a5406a 2887# notemodify, mark in commit-ish
06454cb9 2888#
634c42da 2889test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
06454cb9
PW
2890 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2891 commit refs/heads/Snotes
2892 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2893 data <<COMMIT
a8a5406a 2894 commit S note commit-ish
06454cb9
PW
2895 COMMIT
2896 N :202 :302x
2897 EOF
2898 cat err &&
2899 test_i18ngrep "after mark" err
2900'
2901
2902#
2903# from
2904#
2905test_expect_success 'S: from with garbage after mark must fail' '
0a5e3c50
JK
2906 test_must_fail \
2907 git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&
06454cb9
PW
2908 commit refs/heads/S2
2909 mark :303
2910 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2911 data <<COMMIT
2912 commit 3
2913 COMMIT
2914 from :301x
2915 M 100644 :403 hello.c
2916 EOF
2917
06454cb9
PW
2918
2919 # go create the commit, need it for merge test
2920 git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
2921 commit refs/heads/S2
2922 mark :303
2923 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2924 data <<COMMIT
2925 commit 3
2926 COMMIT
2927 from :301
2928 M 100644 :403 hello.c
2929 EOF
2930
2931 # now evaluate the error
2932 cat err &&
2933 test_i18ngrep "after mark" err
2934'
2935
2936
2937#
2938# merge
2939#
2940test_expect_success 'S: merge with garbage after mark must fail' '
2941 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2942 commit refs/heads/S
2943 mark :304
2944 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2945 data <<COMMIT
2946 merge 4
2947 COMMIT
2948 from :302
2949 merge :303x
2950 M 100644 :403 hello.c
2951 EOF
2952 cat err &&
2953 test_i18ngrep "after mark" err
2954'
2955
2956#
2957# tag, from markref
2958#
2959test_expect_success 'S: tag with garbage after mark must fail' '
2960 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2961 tag refs/tags/Stag
2962 from :302x
2963 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
2964 data <<TAG
2965 tag S
2966 TAG
2967 EOF
2968 cat err &&
2969 test_i18ngrep "after mark" err
2970'
2971
2972#
2973# cat-blob markref
2974#
2975test_expect_success 'S: cat-blob with garbage after mark must fail' '
2976 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2977 cat-blob :403x
2978 EOF
2979 cat err &&
2980 test_i18ngrep "after mark" err
2981'
2982
2983#
2984# ls markref
2985#
2986test_expect_success 'S: ls with garbage after mark must fail' '
2987 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2988 ls :302x hello.c
2989 EOF
2990 cat err &&
2991 test_i18ngrep "space after mark" err
2992'
2993
2994test_expect_success 'S: ls with garbage after sha1 must fail' '
2995 sha1=$(grep :302 marks | cut -d\ -f2) &&
2996 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2997 ls ${sha1}x hello.c
2998 EOF
2999 cat err &&
3000 test_i18ngrep "space after tree-ish" err
3001'
3002
aca70610
JK
3003###
3004### series T (ls)
3005###
3006# Setup is carried over from series S.
3007
e0eb6b97 3008test_expect_success 'T: ls root tree' '
aca70610
JK
3009 sed -e "s/Z\$//" >expect <<-EOF &&
3010 040000 tree $(git rev-parse S^{tree}) Z
3011 EOF
3012 sha1=$(git rev-parse --verify S) &&
3013 git fast-import --import-marks=marks <<-EOF >actual &&
3014 ls $sha1 ""
3015 EOF
3016 test_cmp expect actual
3017'
3018
4ee1b225
FC
3019test_expect_success 'T: delete branch' '
3020 git branch to-delete &&
3021 git fast-import <<-EOF &&
3022 reset refs/heads/to-delete
3023 from 0000000000000000000000000000000000000000
3024 EOF
3025 test_must_fail git rev-parse --verify refs/heads/to-delete
3026'
3027
3028test_expect_success 'T: empty reset doesnt delete branch' '
3029 git branch not-to-delete &&
3030 git fast-import <<-EOF &&
3031 reset refs/heads/not-to-delete
3032 EOF
3033 git show-ref &&
3034 git rev-parse --verify refs/heads/not-to-delete
3035'
3036
8d30d8a8
MB
3037###
3038### series U (filedelete)
3039###
3040
8d30d8a8 3041test_expect_success 'U: initialize for U tests' '
68297e0f
JS
3042 cat >input <<-INPUT_END &&
3043 commit refs/heads/U
3044 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3045 data <<COMMIT
3046 test setup
3047 COMMIT
3048 M 100644 inline hello.c
3049 data <<BLOB
3050 blob 1
3051 BLOB
3052 M 100644 inline good/night.txt
3053 data <<BLOB
3054 sleep well
3055 BLOB
3056 M 100644 inline good/bye.txt
3057 data <<BLOB
3058 au revoir
3059 BLOB
3060
3061 INPUT_END
3062
8d30d8a8
MB
3063 git fast-import <input
3064'
3065
68297e0f
JS
3066test_expect_success 'U: filedelete file succeeds' '
3067 cat >input <<-INPUT_END &&
3068 commit refs/heads/U
3069 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3070 data <<COMMIT
3071 delete good/night.txt
3072 COMMIT
3073 from refs/heads/U^0
3074 D good/night.txt
8d30d8a8 3075
68297e0f 3076 INPUT_END
8d30d8a8 3077
8d30d8a8
MB
3078 git fast-import <input
3079'
3080
68297e0f
JS
3081test_expect_success 'U: validate file delete result' '
3082 cat >expect <<-EOF &&
3083 :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
3084 EOF
8d30d8a8 3085
68297e0f 3086 git diff-tree -M -r U^1 U >actual &&
8d30d8a8 3087
8d30d8a8
MB
3088 compare_diff_raw expect actual
3089'
3090
68297e0f
JS
3091test_expect_success 'U: filedelete directory succeeds' '
3092 cat >input <<-INPUT_END &&
3093 commit refs/heads/U
3094 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3095 data <<COMMIT
3096 delete good dir
3097 COMMIT
3098 from refs/heads/U^0
3099 D good
8d30d8a8 3100
68297e0f 3101 INPUT_END
8d30d8a8 3102
8d30d8a8
MB
3103 git fast-import <input
3104'
3105
68297e0f
JS
3106test_expect_success 'U: validate directory delete result' '
3107 cat >expect <<-EOF &&
3108 :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
3109 EOF
8d30d8a8 3110
68297e0f 3111 git diff-tree -M -r U^1 U >actual &&
8d30d8a8 3112
8d30d8a8
MB
3113 compare_diff_raw expect actual
3114'
3115
68297e0f
JS
3116test_expect_success 'U: filedelete root succeeds' '
3117 cat >input <<-INPUT_END &&
3118 commit refs/heads/U
3119 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3120 data <<COMMIT
3121 must succeed
3122 COMMIT
3123 from refs/heads/U^0
3124 D ""
8d30d8a8 3125
68297e0f 3126 INPUT_END
8d30d8a8 3127
d67824fe 3128 git fast-import <input
8d30d8a8
MB
3129'
3130
68297e0f
JS
3131test_expect_success 'U: validate root delete result' '
3132 cat >expect <<-EOF &&
3133 :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
3134 EOF
8d30d8a8 3135
68297e0f 3136 git diff-tree -M -r U^1 U >actual &&
8d30d8a8 3137
8d30d8a8
MB
3138 compare_diff_raw expect actual
3139'
3140
30e215a6
ER
3141###
3142### series V (checkpoint)
3143###
3144
3145# The commands in input_file should not produce any output on the file
3146# descriptor set with --cat-blob-fd (or stdout if unspecified).
3147#
3148# To make sure you're observing the side effects of checkpoint *before*
3149# fast-import terminates (and thus writes out its state), check that the
3150# fast-import process is still running using background_import_still_running
3151# *after* evaluating the test conditions.
3152background_import_then_checkpoint () {
3153 options=$1
3154 input_file=$2
3155
3156 mkfifo V.input
3157 exec 8<>V.input
3158 rm V.input
3159
3160 mkfifo V.output
3161 exec 9<>V.output
3162 rm V.output
3163
3164 git fast-import $options <&8 >&9 &
3165 echo $! >V.pid
3166 # We don't mind if fast-import has already died by the time the test
3167 # ends.
3168 test_when_finished "exec 8>&-; exec 9>&-; kill $(cat V.pid) || true"
3169
3170 # Start in the background to ensure we adhere strictly to (blocking)
3171 # pipes writing sequence. We want to assume that the write below could
3172 # block, e.g. if fast-import blocks writing its own output to &9
3173 # because there is no reader on &9 yet.
3174 (
3175 cat "$input_file"
3176 echo "checkpoint"
3177 echo "progress checkpoint"
3178 ) >&8 &
3179
3180 error=1 ;# assume the worst
3181 while read output <&9
3182 do
3183 if test "$output" = "progress checkpoint"
3184 then
3185 error=0
3186 break
3187 fi
3188 # otherwise ignore cruft
3189 echo >&2 "cruft: $output"
3190 done
3191
3192 if test $error -eq 1
3193 then
3194 false
3195 fi
3196}
3197
3198background_import_still_running () {
3199 if ! kill -0 "$(cat V.pid)"
3200 then
3201 echo >&2 "background fast-import terminated too early"
3202 false
3203 fi
3204}
3205
3206test_expect_success PIPE 'V: checkpoint helper does not get stuck with extra output' '
3207 cat >input <<-INPUT_END &&
3208 progress foo
3209 progress bar
3210
3211 INPUT_END
3212
3213 background_import_then_checkpoint "" input &&
3214 background_import_still_running
3215'
3216
3217test_expect_success PIPE 'V: checkpoint updates refs after reset' '
3218 cat >input <<-\INPUT_END &&
3219 reset refs/heads/V
3220 from refs/heads/U
3221
3222 INPUT_END
3223
3224 background_import_then_checkpoint "" input &&
3225 test "$(git rev-parse --verify V)" = "$(git rev-parse --verify U)" &&
3226 background_import_still_running
3227'
3228
3229test_expect_success PIPE 'V: checkpoint updates refs and marks after commit' '
3230 cat >input <<-INPUT_END &&
3231 commit refs/heads/V
3232 mark :1
3233 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3234 data 0
3235 from refs/heads/U
3236
3237 INPUT_END
3238
3239 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3240
3241 echo ":1 $(git rev-parse --verify V)" >marks.expected &&
3242
3243 test "$(git rev-parse --verify V^)" = "$(git rev-parse --verify U)" &&
3244 test_cmp marks.expected marks.actual &&
3245 background_import_still_running
3246'
3247
3248# Re-create the exact same commit, but on a different branch: no new object is
3249# created in the database, but the refs and marks still need to be updated.
3250test_expect_success PIPE 'V: checkpoint updates refs and marks after commit (no new objects)' '
3251 cat >input <<-INPUT_END &&
3252 commit refs/heads/V2
3253 mark :2
3254 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3255 data 0
3256 from refs/heads/U
3257
3258 INPUT_END
3259
3260 background_import_then_checkpoint "--export-marks=marks.actual" input &&
3261
3262 echo ":2 $(git rev-parse --verify V2)" >marks.expected &&
3263
3264 test "$(git rev-parse --verify V2)" = "$(git rev-parse --verify V)" &&
3265 test_cmp marks.expected marks.actual &&
3266 background_import_still_running
3267'
3268
3269test_expect_success PIPE 'V: checkpoint updates tags after tag' '
3270 cat >input <<-INPUT_END &&
3271 tag Vtag
3272 from refs/heads/V
3273 tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
3274 data 0
3275
3276 INPUT_END
3277
3278 background_import_then_checkpoint "" input &&
3279 git show-ref -d Vtag &&
3280 background_import_still_running
3281'
3282
50aee995 3283test_done