#!/bin/sh # # Copyright (c) 2007 Shawn Pearce # global test_description := ''test git fast-import utility'' source ./test-lib.sh source "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash proc verify_packs { for p in [.git/objects/pack/*.pack] { git verify-pack @Argv $p || return } } global file2_data := ''file2 second line of EOF'' global file3_data := ''EOF in 3rd file END'' global file4_data := 'abcd' global file4_len := '4' global file5_data := ''an inline file. we should see it later.'' global file6_data := ''#!/bin/sh echo "$@"'' ### ### series A ### test_expect_success 'empty stream succeeds' ' git config fastimport.unpackLimit 0 && git fast-import input <<-INPUT_END && blob mark :2 data < $GIT_COMMITTER_DATE data <expect <<-EOF && author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE initial EOF git cat-file commit master | sed 1d >actual && test_cmp expect actual ' test_expect_success 'A: verify tree' ' cat >expect <<-EOF && 100644 blob file2 100644 blob file3 100755 blob file4 EOF git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'A: verify file2' ' echo "$file2_data" >expect && git cat-file blob master:file2 >actual && test_cmp expect actual ' test_expect_success 'A: verify file3' ' echo "$file3_data" >expect && git cat-file blob master:file3 >actual && test_cmp expect actual ' test_expect_success 'A: verify file4' ' printf "$file4_data" >expect && git cat-file blob master:file4 >actual && test_cmp expect actual ' test_expect_success 'A: verify tag/series-A' ' cat >expect <<-EOF && object $(git rev-parse refs/heads/master) type commit tag series-A An annotated tag without a tagger EOF git cat-file tag tags/series-A >actual && test_cmp expect actual ' test_expect_success 'A: verify tag/series-A-blob' ' cat >expect <<-EOF && object $(git rev-parse refs/heads/master:file3) type blob tag series-A-blob An annotated tag that annotates a blob. EOF git cat-file tag tags/series-A-blob >actual && test_cmp expect actual ' test_expect_success 'A: verify marks output' ' cat >expect <<-EOF && :2 $(git rev-parse --verify master:file2) :3 $(git rev-parse --verify master:file3) :4 $(git rev-parse --verify master:file4) :5 $(git rev-parse --verify master^0) EOF test_cmp expect marks.out ' test_expect_success 'A: verify marks import' ' git fast-import \ --import-marks=marks.out \ --export-marks=marks.new \ input <<-INPUT_END && tag series-A-blob-2 from $(git rev-parse refs/heads/master:file3) data < 0 +0000 data 0 M 644 :6 new_blob #pretend we got sha1 from fast-import ls "new_blob" tag series-A-blob-3 from $new_blob data <expect <<-EOF && object $(git rev-parse refs/heads/master:file3) type blob tag series-A-blob-2 Tag blob by sha1. object $new_blob type blob tag series-A-blob-3 Tag new_blob. EOF git fast-import actual && git cat-file tag tags/series-A-blob-3 >>actual && test_cmp expect actual ' test_expect_success 'A: verify marks import does not crash' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/verify--import-marks committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2 EOF git diff-tree -M -r master verify--import-marks >actual && compare_diff_raw expect actual && test $(git rev-parse --verify master:file2) \ = $(git rev-parse --verify verify--import-marks:copy-of-file2) ' test_expect_success 'A: export marks with large values' ' test_tick && mt=$(git hash-object --stdin < /dev/null) && >input.blob && >marks.exp && >tree.exp && cat >input.commit <<-EOF && commit refs/heads/verify--dump-marks committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <>input.blob <<-EOF && blob mark :$l data 0 blob mark :$m data 0 blob mark :$n data 0 EOF echo "M 100644 :$l l$i" >>input.commit && echo "M 100644 :$m m$i" >>input.commit && echo "M 100644 :$n n$i" >>input.commit && echo ":$l $mt" >>marks.exp && echo ":$m $mt" >>marks.exp && echo ":$n $mt" >>marks.exp && printf "100644 blob $mt\tl$i\n" >>tree.exp && printf "100644 blob $mt\tm$i\n" >>tree.exp && printf "100644 blob $mt\tn$i\n" >>tree.exp && l=$(($l + $l)) && m=$(($m + $m)) && n=$(($l + $n)) && i=$((1 + $i)) || return 1 done && sort tree.exp > tree.exp_s && cat input.blob input.commit | git fast-import --export-marks=marks.large && git ls-tree refs/heads/verify--dump-marks >tree.out && test_cmp tree.exp_s tree.out && test_cmp marks.exp marks.large ' ### ### series B ### test_expect_success 'B: fail on invalid blob sha1' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/branch mark :1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit TEMP_TAG committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/empty-committer-1 committer <> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/empty-committer-2 committer $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/invalid-committer committer Name email> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/invalid-committer committer Name $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/invalid-committer committer Name > $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/invalid-committer committer Name input <<-INPUT_END && commit refs/heads/invalid-committer committer Name $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/branch committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && parent $(git rev-parse --verify master^0) author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE second EOF git cat-file commit branch | sed 1d >actual && test_cmp expect actual ' test_expect_success 'C: validate rename result' ' cat >expect <<-EOF && :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf :100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3 EOF git diff-tree -M -r master branch >actual && compare_diff_raw expect actual ' ### ### series D ### test_expect_success 'D: inline data in commit' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/branch committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh :000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting EOF git diff-tree -M -r branch^ branch >actual && compare_diff_raw expect actual ' test_expect_success 'D: verify file5' ' echo "$file5_data" >expect && git cat-file blob branch:newdir/interesting >actual && test_cmp expect actual ' test_expect_success 'D: verify file6' ' echo "$file6_data" >expect && git cat-file blob branch:newdir/exec.sh >actual && test_cmp expect actual ' ### ### series E ### test_expect_success 'E: rfc2822 date, --date-format=raw' ' cat >input <<-INPUT_END && commit refs/heads/branch author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500 data <expect <<-EOF && author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500 RFC 2822 type date EOF git cat-file commit branch | sed 1,2d >actual && test_cmp expect actual ' ### ### series F ### test_expect_success 'F: non-fast-forward update skips' ' old_branch=$(git rev-parse --verify branch^0) && test_tick && cat >input <<-INPUT_END && commit refs/heads/branch committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && tree $(git rev-parse branch~1^{tree}) parent $(git rev-parse branch~1) author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE losing things already? EOF git cat-file commit other >actual && test_cmp expect actual ' ### ### series G ### test_expect_success 'G: non-fast-forward update forced' ' old_branch=$(git rev-parse --verify branch^0) && test_tick && cat >input <<-INPUT_END && commit refs/heads/branch committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/H committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf :100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4 :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo :100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh EOF git diff-tree -M -r H^ H >actual && compare_diff_raw expect actual ' test_expect_success 'H: verify file' ' echo "$file5_data" >expect && git cat-file blob H:h/e/l/lo >actual && test_cmp expect actual ' ### ### series I ### test_expect_success 'I: export-pack-edges' ' cat >input <<-INPUT_END && commit refs/heads/export-boundary committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary) EOF sed -e s/pack-.*pack/pack-.pack/ edges.list >actual && test_cmp expect actual ' ### ### series J ### test_expect_success 'J: reset existing branch creates empty commit' ' cat >input <<-INPUT_END && commit refs/heads/J committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <input <<-INPUT_END && reset refs/heads/J2 tag wrong_tag from refs/heads/J2 data <input <<-INPUT_END && commit refs/heads/K committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <input <<-INPUT_END && blob mark :1 data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <expect <<-EXPECT_END && :100644 100644 4268632... 55d3a52... M b. :040000 040000 0ae5cac... 443c768... M b :100644 100644 4268632... 55d3a52... M ba EXPECT_END git fast-import output && test_cmp expect output ' test_expect_success 'L: nested tree copy does not corrupt deltas' ' cat >input <<-INPUT_END && blob mark :1 data < 1112912473 -0700 data < 1112912473 -0700 data <expect <<-\EOF && g/b/f g/b/h EOF test_when_finished "git update-ref -d refs/heads/L2" && git fast-import tmp && cat tmp | cut -f 2 >actual && test_cmp expect actual && git fsck $(git rev-parse L2) ' ### ### series M ### test_expect_success 'M: rename file in same subdirectory' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/M1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f EOF git fast-import actual && compare_diff_raw expect actual ' test_expect_success 'M: rename file to new subdirectory' ' cat >input <<-INPUT_END && commit refs/heads/M2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you EOF git fast-import actual && compare_diff_raw expect actual ' test_expect_success 'M: rename subdirectory to new subdirectory' ' cat >input <<-INPUT_END && commit refs/heads/M3 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you EOF git fast-import actual && compare_diff_raw expect actual ' test_expect_success 'M: rename root to subdirectory' ' cat >input <<-INPUT_END && commit refs/heads/M4 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting EOF git fast-import actual && cat actual && compare_diff_raw expect actual ' ### ### series N ### test_expect_success 'N: copy file in same subdirectory' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/N1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f EOF git fast-import actual && compare_diff_raw expect actual ' test_expect_success 'N: copy then modify subdirectory' ' cat >input <<-INPUT_END && commit refs/heads/N2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <expect <<-EOF && :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf EOF git fast-import actual && compare_diff_raw expect actual ' test_expect_success 'N: copy dirty subdirectory' ' cat >input <<-INPUT_END && commit refs/heads/N3 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-\EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf EOF subdir=$(git rev-parse refs/heads/branch^0:file2) && cat >input <<-INPUT_END && commit refs/heads/N4 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <actual && compare_diff_raw expect actual ' test_expect_success PIPE 'N: read and copy directory' ' cat >expect <<-\EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf EOF git update-ref -d refs/heads/N4 && rm -f backflow && mkfifo backflow && ( exec $GIT_COMMITTER_DATE data <backflow && git diff-tree -C --find-copies-harder -r N4^ N4 >actual && compare_diff_raw expect actual ' test_expect_success PIPE 'N: empty directory reads as missing' ' cat <<-\EOF >expect && OBJNAME :000000 100644 OBJNAME OBJNAME A unrelated EOF echo "missing src" >expect.response && git update-ref -d refs/heads/read-empty && rm -f backflow && mkfifo backflow && ( exec $GIT_COMMITTER_DATE data <response && cat <<-\EOF D dst1 D dst2 EOF ) | git fast-import --cat-blob-fd=3 3>backflow && test_cmp expect.response response && git rev-list read-empty | git diff-tree -r --root --stdin | sed "s/$_x40/OBJNAME/g" >actual && test_cmp expect actual ' test_expect_success 'N: copy root directory by tree hash' ' cat >expect <<-\EOF && :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf EOF root=$(git rev-parse refs/heads/branch^0^{tree}) && cat >input <<-INPUT_END && commit refs/heads/N6 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <actual && compare_diff_raw expect actual ' test_expect_success 'N: copy root by path' ' cat >expect <<-\EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4 :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting EOF cat >input <<-INPUT_END && commit refs/heads/N-copy-root-path committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <actual && compare_diff_raw expect actual ' test_expect_success 'N: delete directory by copying' ' cat >expect <<-\EOF && OBJID :100644 000000 OBJID OBJID D foo/bar/qux OBJID :000000 100644 OBJID OBJID A foo/bar/baz :000000 100644 OBJID OBJID A foo/bar/qux EOF empty_tree=$(git mktree input <<-INPUT_END && commit refs/heads/N-delete committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <actual && test_cmp expect actual ' test_expect_success 'N: modify copied tree' ' cat >expect <<-\EOF && :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf EOF subdir=$(git rev-parse refs/heads/branch^0:file2) && cat >input <<-INPUT_END && commit refs/heads/N5 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <actual && compare_diff_raw expect actual ' test_expect_success 'N: reject foo/ syntax' ' subdir=$(git rev-parse refs/heads/branch^0:file2) && test_must_fail git fast-import <<-INPUT_END commit refs/heads/N5B committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <expect.foo && echo hello >expect.bar && git fast-import <<-SETUP_END && commit refs/heads/N7 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <actual.foo && git show N8:foo/bar >actual.bar && test_cmp expect.foo actual.foo && test_cmp expect.bar actual.bar ' test_expect_success 'N: extract subtree' ' branch=$(git rev-parse --verify refs/heads/branch^{tree}) && cat >input <<-INPUT_END && commit refs/heads/N9 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect.baz && echo hello, world >expect.qux && git fast-import <<-SETUP_END && commit refs/heads/N10 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <actual.baz && git show N11:bar/qux >actual.qux && git show N11:bar/quux >actual.quux && test_cmp expect.baz actual.baz && test_cmp expect.qux actual.qux && test_cmp expect.qux actual.quux' ### ### series O ### test_expect_success 'O: comments are all skipped' ' cat >input <<-INPUT_END && #we will commit refs/heads/O1 # -- ignore all of this text committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE # $GIT_COMMITTER_NAME has inserted here for his benefit. data <input <<-INPUT_END && commit refs/heads/O2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/O3 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <expect <<-INPUT_END && string of empty commits INPUT_END git fast-import actual && test_cmp expect actual ' test_expect_success 'O: progress outputs as requested by input' ' cat >input <<-INPUT_END && commit refs/heads/O4 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <actual && grep "progress " expect && test_cmp expect actual ' ### ### series P (gitlinks) ### test_expect_success 'P: superproject & submodule mix' ' cat >input <<-INPUT_END && blob mark :1 data 10 test file reset refs/heads/sub commit refs/heads/sub mark :2 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 12 sub_initial M 100644 :1 file blob mark :3 data < $GIT_COMMITTER_DATE data 8 initial from refs/heads/master M 100644 :3 .gitmodules M 160000 :2 sub blob mark :5 data 20 test file more data commit refs/heads/sub mark :6 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 11 sub_second from :2 M 100644 :5 file commit refs/heads/subuse1 mark :7 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 7 second from :4 M 160000 :6 sub INPUT_END git fast-import input <<-INPUT_END && blob mark :1 data < $GIT_COMMITTER_DATE data 8 initial from refs/heads/master M 100644 :1 .gitmodules M 160000 $SUBPREV sub commit refs/heads/subuse2 mark :3 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data 7 second from :2 M 160000 $SUBLAST sub INPUT_END git branch -D sub && git gc && git prune && git fast-import input <<-INPUT_END && commit refs/heads/subuse3 mark :1 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && blob mark :1 data < $GIT_COMMITTER_DATE data <input <<-INPUT_END && blob mark :2 data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <expect <<-EOF && author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE first (:3) EOF git cat-file commit notes-test~2 | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify second commit' ' cat >expect <<-EOF && parent $commit1 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE second (:5) EOF git cat-file commit notes-test^ | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify third commit' ' cat >expect <<-EOF && parent $commit2 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE third (:6) EOF git cat-file commit notes-test | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify first notes commit' ' cat >expect <<-EOF && author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE notes (:9) EOF git cat-file commit refs/notes/foobar~2 | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify first notes tree' ' cat >expect.unsorted <<-EOF && 100644 blob $commit1 100644 blob $commit2 100644 blob $commit3 EOF cat expect.unsorted | sort >expect && git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'Q: verify first note for first commit' ' echo "$note1_data" >expect && git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual ' test_expect_success 'Q: verify first note for second commit' ' echo "$note2_data" >expect && git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual ' test_expect_success 'Q: verify first note for third commit' ' echo "$note3_data" >expect && git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual ' test_expect_success 'Q: verify second notes commit' ' cat >expect <<-EOF && parent $(git rev-parse --verify refs/notes/foobar~2) author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE notes (:10) EOF git cat-file commit refs/notes/foobar^ | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify second notes tree' ' cat >expect.unsorted <<-EOF && 100644 blob $commit1 100644 blob $commit2 100644 blob $commit3 EOF cat expect.unsorted | sort >expect && git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'Q: verify second note for first commit' ' echo "$note1b_data" >expect && git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual ' test_expect_success 'Q: verify first note for second commit' ' echo "$note2_data" >expect && git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual ' test_expect_success 'Q: verify first note for third commit' ' echo "$note3_data" >expect && git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual ' test_expect_success 'Q: verify third notes commit' ' cat >expect <<-EOF && author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE notes (:11) EOF git cat-file commit refs/notes/foobar2 | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify third notes tree' ' cat >expect.unsorted <<-EOF && 100644 blob $commit1 EOF cat expect.unsorted | sort >expect && git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'Q: verify third note for first commit' ' echo "$note1c_data" >expect && git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual ' test_expect_success 'Q: verify fourth notes commit' ' cat >expect <<-EOF && parent $(git rev-parse --verify refs/notes/foobar^) author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE notes (:12) EOF git cat-file commit refs/notes/foobar | sed 1d >actual && test_cmp expect actual ' test_expect_success 'Q: verify fourth notes tree' ' cat >expect.unsorted <<-EOF && 100644 blob $commit2 EOF cat expect.unsorted | sort >expect && git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual && test_cmp expect actual ' test_expect_success 'Q: verify second note for second commit' ' echo "$note2b_data" >expect && git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual ' test_expect_success 'Q: deny note on empty branch' ' cat >input <<-EOF && reset refs/heads/Q0 commit refs/heads/note-Q0 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-EOF && feature no-such-feature-exists EOF test_must_fail git fast-import input <<-EOF && feature date-format=now EOF git fast-import input <<-EOF && blob data 3 hi feature date-format=now EOF test_must_fail git fast-import input <<-EOF && feature import-marks=git.marks feature import-marks=git2.marks EOF test_must_fail git fast-import input <<-EOF && feature export-marks=git.marks blob mark :1 data 3 hi EOF cat input | git fast-import && grep :1 git.marks ' test_expect_success 'R: export-marks options can be overridden by commandline options' ' cat input | git fast-import --export-marks=other.marks && grep :1 other.marks ' test_expect_success 'R: catch typo in marks file name' ' test_must_fail git fast-import --import-marks=nonexistent.marks expect <<-EOF && :1 $blob :2 $blob EOF git fast-import --export-marks=io.marks <<-\EOF && blob mark :1 data 3 hi EOF git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && blob mark :2 data 3 hi EOF test_cmp expect io.marks ' test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' ' rm -f io.marks && test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF blob mark :1 data 3 hi EOF ' test_expect_success 'R: --import-marks-if-exists' ' rm -f io.marks && blob=$(echo hi | git hash-object --stdin) && echo ":1 $blob" >expect && git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF && blob mark :1 data 3 hi EOF test_cmp expect io.marks ' test_expect_success 'R: feature import-marks-if-exists' ' rm -f io.marks && >expect && git fast-import --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=not_io.marks EOF test_cmp expect io.marks && blob=$(echo hi | git hash-object --stdin) && echo ":1 $blob" >io.marks && echo ":1 $blob" >expect && echo ":2 $blob" >>expect && git fast-import --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=io.marks blob mark :2 data 3 hi EOF test_cmp expect io.marks && echo ":3 $blob" >>expect && git fast-import --import-marks=io.marks \ --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=not_io.marks blob mark :3 data 3 hi EOF test_cmp expect io.marks && >expect && git fast-import --import-marks-if-exists=not_io.marks \ --export-marks=io.marks <<-\EOF && feature import-marks-if-exists=io.marks EOF test_cmp expect io.marks ' test_expect_success 'R: import to output marks works without any content' ' cat >input <<-EOF && feature import-marks=marks.out feature export-marks=marks.new EOF cat input | git fast-import && test_cmp marks.out marks.new ' test_expect_success 'R: import marks prefers commandline marks file over the stream' ' cat >input <<-EOF && feature import-marks=nonexistent.marks feature export-marks=marks.new EOF cat input | git fast-import --import-marks=marks.out && test_cmp marks.out marks.new ' test_expect_success 'R: multiple --import-marks= should be honoured' ' cat >input <<-EOF && feature import-marks=nonexistent.marks feature export-marks=combined.marks EOF head -n2 marks.out > one.marks && tail -n +3 marks.out > two.marks && git fast-import --import-marks=one.marks --import-marks=two.marks input <<-EOF && feature relative-marks feature import-marks=relative.in feature export-marks=relative.out EOF mkdir -p .git/info/fast-import/ && cp marks.new .git/info/fast-import/relative.in && git fast-import input <<-EOF && feature relative-marks feature import-marks=relative.in feature no-relative-marks feature export-marks=non-relative.out EOF git fast-import expect <<-EOF && ${blob} blob 11 yes it can EOF echo "cat-blob $blob" | git fast-import --cat-blob-fd=6 6>actual && test_cmp expect actual ' test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' ' echo hello >greeting && blob=$(git hash-object -w greeting) && cat >expect <<-EOF && ${blob} blob 6 hello EOF git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF && cat-blob $blob EOF test_cmp expect actual.3 && test_must_be_empty actual.1 && git fast-import 3>actual.3 >actual.1 <<-EOF && option cat-blob-fd=3 cat-blob $blob EOF test_must_be_empty actual.3 && test_cmp expect actual.1 ' test_expect_success !MINGW 'R: print mark for new blob' ' echo "effluentish" | git hash-object --stdin >expect && git fast-import --cat-blob-fd=6 6>actual <<-\EOF && blob mark :1 data <expect <<-EOF && ${blob} blob 12 yep yep yep EOF git fast-import --cat-blob-fd=6 6>actual <<-\EOF && blob mark :1 data <expect <<-EOF && ${blob} blob 25 a new blob named by sha1 EOF git fast-import --cat-blob-fd=6 6>actual <<-EOF && blob data <big && for i in 1 2 3 do cat big big big big >bigger && cat bigger bigger bigger bigger >big || exit done ) ' test_expect_success 'R: print two blobs to stdout' ' blob1=$(git hash-object big) && blob1_len=$(wc -c expect && { cat <<-\END_PART1 && blob mark :1 data <actual && test_cmp expect actual ' test_expect_success PIPE 'R: copy using cat-file' ' expect_id=$(git hash-object big) && expect_len=$(wc -c expect.response && rm -f blobs && cat >frontend <<-\FRONTEND_END && #!/bin/sh FRONTEND_END mkfifo blobs && ( export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE && cat <<-\EOF && feature cat-blob blob mark :1 data <response && test_copy_bytes $size >blob <&3 && read newline <&3 && cat <<-EOF && commit refs/heads/copied committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <blobs && git show copied:file3 >actual && test_cmp expect.response response && test_cmp big actual ' test_expect_success PIPE 'R: print blob mid-commit' ' rm -f blobs && echo "A blob from _before_ the commit." >expect && mkfifo blobs && ( exec 3 $GIT_COMMITTER_DATE data <actual <&3 && read newline <&3 && echo ) | git fast-import --cat-blob-fd=3 3>blobs && test_cmp expect actual ' test_expect_success PIPE 'R: print staged blob within commit' ' rm -f blobs && echo "A blob from _within_ the commit." >expect && mkfifo blobs && ( exec 3 $GIT_COMMITTER_DATE data <actual <&3 && read newline <&3 && echo deleteall ) | git fast-import --cat-blob-fd=3 3>blobs && test_cmp expect actual ' test_expect_success 'R: quiet option results in no stats being output' ' cat >input <<-EOF && option git quiet blob data 3 hi EOF cat input | git fast-import 2> output && test_must_be_empty output ' test_expect_success 'R: feature done means terminating "done" is mandatory' ' echo feature done | test_must_fail git fast-import && test_must_fail git fast-import --done expect <<-\EOF && OBJID :000000 100644 OBJID OBJID A hello.c :000000 100644 OBJID OBJID A hello2.c EOF git fast-import <<-EOF && commit refs/heads/done-ends committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <actual && test_cmp expect actual ' test_expect_success 'R: die on unknown option' ' cat >input <<-EOF && option git non-existing-option EOF test_must_fail git fast-import input <<-EOF && option non-existing-vcs non-existing-option EOF git fast-import expect <<-EOF && :3 0000000000000000000000000000000000000000 :1 $blob :2 $blob EOF cp expect io.marks && test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF && EOF test_cmp expect io.marks ' ## ## R: very large blobs ## test_expect_success 'R: blob bigger than threshold' ' blobsize=$((2*1024*1024 + 53)) && test-genrandom bar $blobsize >expect && cat >input <<-INPUT_END && commit refs/heads/big-file committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <>input && cat >>input <<-INPUT_END && M 644 inline big2 data $blobsize INPUT_END cat expect >>input && echo >>input && test_create_repo R && git --git-dir=R/.git config fastimport.unpackLimit 0 && git --git-dir=R/.git fast-import --big-file-threshold=1 ../verify ) ' test_expect_success 'R: verify written objects' ' git --git-dir=R/.git cat-file blob big-file:big1 >actual && test_cmp_bin expect actual && a=$(git --git-dir=R/.git rev-parse big-file:big1) && b=$(git --git-dir=R/.git rev-parse big-file:big2) && test $a = $b ' test_expect_success 'R: blob appears only once' ' n=$(grep $a verify | wc -l) && test 1 = $n ' ### ### series S ### # # Make sure missing spaces and EOLs after mark references # cause errors. # # Setup: # # 1--2--4 # \ / # -3- # # commit marks: 301, 302, 303, 304 # blob marks: 403, 404, resp. # note mark: 202 # # The error message when a space is missing not at the # end of the line is: # # Missing space after .. # # or when extra characters come after the mark at the end # of the line: # # Garbage after .. # # or when the dataref is neither "inline " or a known SHA1, # # Invalid dataref .. # test_expect_success 'S: initialize for S tests' ' test_tick && cat >input <<-INPUT_END && commit refs/heads/S mark :301 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/Snotes committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && commit refs/heads/S2 mark :303 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data < $GIT_COMMITTER_DATE data <err && commit refs/heads/S mark :304 committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && tag refs/tags/Stag from :302x tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <err && cat-blob :403x EOF cat err && test_i18ngrep "after mark" err ' # # ls markref # test_expect_success 'S: ls with garbage after mark must fail' ' test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && ls :302x hello.c EOF cat err && test_i18ngrep "space after mark" err ' test_expect_success 'S: ls with garbage after sha1 must fail' ' sha1=$(grep :302 marks | cut -d\ -f2) && test_must_fail git fast-import --import-marks=marks <<-EOF 2>err && ls ${sha1}x hello.c EOF cat err && test_i18ngrep "space after tree-ish" err ' ### ### series T (ls) ### # Setup is carried over from series S. test_expect_success 'T: ls root tree' ' sed -e "s/Z\$//" >expect <<-EOF && 040000 tree $(git rev-parse S^{tree}) Z EOF sha1=$(git rev-parse --verify S) && git fast-import --import-marks=marks <<-EOF >actual && ls $sha1 "" EOF test_cmp expect actual ' test_expect_success 'T: delete branch' ' git branch to-delete && git fast-import <<-EOF && reset refs/heads/to-delete from 0000000000000000000000000000000000000000 EOF test_must_fail git rev-parse --verify refs/heads/to-delete ' test_expect_success 'T: empty reset doesnt delete branch' ' git branch not-to-delete && git fast-import <<-EOF && reset refs/heads/not-to-delete EOF git show-ref && git rev-parse --verify refs/heads/not-to-delete ' ### ### series U (filedelete) ### test_expect_success 'U: initialize for U tests' ' cat >input <<-INPUT_END && commit refs/heads/U committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <input <<-INPUT_END && commit refs/heads/U committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt EOF git diff-tree -M -r U^1 U >actual && compare_diff_raw expect actual ' test_expect_success 'U: filedelete directory succeeds' ' cat >input <<-INPUT_END && commit refs/heads/U committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt EOF git diff-tree -M -r U^1 U >actual && compare_diff_raw expect actual ' test_expect_success 'U: filedelete root succeeds' ' cat >input <<-INPUT_END && commit refs/heads/U committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE data <expect <<-EOF && :100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c EOF git diff-tree -M -r U^1 U >actual && compare_diff_raw expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test git fast-import utility">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (Sentence child: (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/diff-lib.sh)}) terminator: ) (FuncDef name: verify_packs body: (BraceGroup children: [ (ForEach iter_name: p iter_words: [{(.git/objects/pack/) (Lit_Other "*") (.pack)}] do_arg_iter: False body: (DoGroup children: [ (AndOr children: [ (C {(git)} {(verify-pack)} {(DQ ($ VSub_At "$@"))} {(DQ ($ VSub_Name "$p"))}) (ControlFlow token:) ] op_id: Op_DPipe ) ] spids: [53 73] ) spids: [47 -1] ) ] spids: [39] ) spids: [34 38] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file2_data) op: Equal rhs: {(SQ <"file2\n"> <"second line of EOF">)} spids: [78] ) ] spids: [78] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file3_data) op: Equal rhs: {(SQ <"EOF\n"> <"in 3rd file\n"> <" END">)} spids: [85] ) ] spids: [85] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:file4_data) op:Equal rhs:{(abcd)} spids:[93])] spids: [93] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:file4_len) op:Equal rhs:{(4)} spids:[96])] spids: [96] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file5_data) op: Equal rhs: {(SQ <"an inline file.\n"> <" we should see it later.">)} spids: [100] ) ] spids: [100] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:file6_data) op: Equal rhs: {(SQ <"#!/bin/sh\n"> <"echo \"$@\"">)} spids: [107] ) ] spids: [107] ) (C {(test_expect_success)} {(SQ <"empty stream succeeds">)} {(SQ <"\n"> <"\tgit config fastimport.unpackLimit 0 &&\n"> <"\tgit fast-import )} ) (C {(test_expect_success)} {(SQ <"truncated stream complains">)} {(SQ <"\n"> <"\techo \"tag foo\" | test_must_fail git fast-import\n">)} ) (C {(test_expect_success)} {(SQ <"A: create pack from stdin">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :2\n"> <"\tdata < <"\t$file2_data\n"> <"\tEOF\n"> <"\n"> <"\tblob\n"> <"\tmark :3\n"> <"\tdata < <"\t$file3_data\n"> <"\tEND\n"> <"\n"> <"\tblob\n"> <"\tmark :4\n"> <"\tdata $file4_len\n"> <"\t$file4_data\n"> <"\tcommit refs/heads/master\n"> <"\tmark :5\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tinitial\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 :2 file2\n"> <"\tM 644 :3 file3\n"> <"\tM 755 :4 file4\n"> <"\n"> <"\ttag series-A\n"> <"\tfrom :5\n"> <"\tdata < <"\tAn annotated tag without a tagger\n"> <"\tEOF\n"> <"\n"> <"\ttag series-A-blob\n"> <"\tfrom :3\n"> <"\tdata < <"\tAn annotated tag that annotates a blob.\n"> <"\tEOF\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import --export-marks=marks.out <"\tgit whatchanged master\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"A: verify commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tinitial\n"> <"\tEOF\n"> <"\tgit cat-file commit master | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify tree">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t100644 blob file2\n"> <"\t100644 blob file3\n"> <"\t100755 blob file4\n"> <"\tEOF\n"> <"\tgit cat-file -p master^{tree} | sed \"s/ [0-9a-f]*\t/ /\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify file2">)} { (SQ <"\n"> <"\techo \"$file2_data\" >expect &&\n"> <"\tgit cat-file blob master:file2 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify file3">)} { (SQ <"\n"> <"\techo \"$file3_data\" >expect &&\n"> <"\tgit cat-file blob master:file3 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify file4">)} { (SQ <"\n"> <"\tprintf \"$file4_data\" >expect &&\n"> <"\tgit cat-file blob master:file4 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify tag/series-A">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tobject $(git rev-parse refs/heads/master)\n"> <"\ttype commit\n"> <"\ttag series-A\n"> <"\n"> <"\tAn annotated tag without a tagger\n"> <"\tEOF\n"> <"\tgit cat-file tag tags/series-A >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify tag/series-A-blob">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tobject $(git rev-parse refs/heads/master:file3)\n"> <"\ttype blob\n"> <"\ttag series-A-blob\n"> <"\n"> <"\tAn annotated tag that annotates a blob.\n"> <"\tEOF\n"> <"\tgit cat-file tag tags/series-A-blob >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify marks output">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t:2 $(git rev-parse --verify master:file2)\n"> <"\t:3 $(git rev-parse --verify master:file3)\n"> <"\t:4 $(git rev-parse --verify master:file4)\n"> <"\t:5 $(git rev-parse --verify master^0)\n"> <"\tEOF\n"> <"\ttest_cmp expect marks.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify marks import">)} { (SQ <"\n"> <"\tgit fast-import \\\n"> <"\t\t--import-marks=marks.out \\\n"> <"\t\t--export-marks=marks.new \\\n"> <"\t\t <"\ttest_cmp expect marks.new\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: tag blob by sha1">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tnew_blob=$(echo testing | git hash-object --stdin) &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\ttag series-A-blob-2\n"> <"\tfrom $(git rev-parse refs/heads/master:file3)\n"> <"\tdata < <"\tTag blob by sha1.\n"> <"\tEOF\n"> <"\n"> <"\tblob\n"> <"\tmark :6\n"> <"\tdata < <"\ttesting\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/heads/new_blob\n"> <"\tcommitter <> 0 +0000\n"> <"\tdata 0\n"> <"\tM 644 :6 new_blob\n"> <"\t#pretend we got sha1 from fast-import\n"> <"\tls \"new_blob\"\n"> <"\n"> <"\ttag series-A-blob-3\n"> <"\tfrom $new_blob\n"> <"\tdata < <"\tTag new_blob.\n"> <"\tEOF\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tobject $(git rev-parse refs/heads/master:file3)\n"> <"\ttype blob\n"> <"\ttag series-A-blob-2\n"> <"\n"> <"\tTag blob by sha1.\n"> <"\tobject $new_blob\n"> <"\ttype blob\n"> <"\ttag series-A-blob-3\n"> <"\n"> <"\tTag new_blob.\n"> <"\tEOF\n"> <"\n"> <"\tgit fast-import <"\tgit cat-file tag tags/series-A-blob-2 >actual &&\n"> <"\tgit cat-file tag tags/series-A-blob-3 >>actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify marks import does not crash">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/verify--import-marks\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\trecreate from :5\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom :5\n"> <"\tM 755 :2 copy-of-file2\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import --import-marks=marks.out <"\tgit whatchanged verify--import-marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"A: verify diff">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A\tcopy-of-file2\n" > <"\tEOF\n"> <"\tgit diff-tree -M -r master verify--import-marks >actual &&\n"> <"\tcompare_diff_raw expect actual &&\n"> <"\ttest $(git rev-parse --verify master:file2) \\\n"> <"\t = $(git rev-parse --verify verify--import-marks:copy-of-file2)\n"> ) } ) (C {(test_expect_success)} {(SQ <"A: export marks with large values">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tmt=$(git hash-object --stdin < /dev/null) &&\n"> <"\t>input.blob &&\n"> <"\t>marks.exp &&\n"> <"\t>tree.exp &&\n"> <"\n"> <"\tcat >input.commit <<-EOF &&\n"> <"\tcommit refs/heads/verify--dump-marks\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\ttest the sparse array dumping routines with exponentially growing marks\n"> <"\tCOMMIT\n"> <"\tEOF\n"> <"\n"> <"\ti=0 l=4 m=6 n=7 &&\n"> <"\twhile test \"$i\" -lt 27\n"> <"\tdo\n"> <"\t\tcat >>input.blob <<-EOF &&\n"> <"\t\tblob\n"> <"\t\tmark :$l\n"> <"\t\tdata 0\n"> <"\t\tblob\n"> <"\t\tmark :$m\n"> <"\t\tdata 0\n"> <"\t\tblob\n"> <"\t\tmark :$n\n"> <"\t\tdata 0\n"> <"\t\tEOF\n"> <"\t\techo \"M 100644 :$l l$i\" >>input.commit &&\n"> <"\t\techo \"M 100644 :$m m$i\" >>input.commit &&\n"> <"\t\techo \"M 100644 :$n n$i\" >>input.commit &&\n"> <"\n"> <"\t\techo \":$l $mt\" >>marks.exp &&\n"> <"\t\techo \":$m $mt\" >>marks.exp &&\n"> <"\t\techo \":$n $mt\" >>marks.exp &&\n"> <"\n"> <"\t\tprintf \"100644 blob $mt\\tl$i\\n\" >>tree.exp &&\n"> <"\t\tprintf \"100644 blob $mt\\tm$i\\n\" >>tree.exp &&\n"> <"\t\tprintf \"100644 blob $mt\\tn$i\\n\" >>tree.exp &&\n"> <"\n"> <"\t\tl=$(($l + $l)) &&\n"> <"\t\tm=$(($m + $m)) &&\n"> <"\t\tn=$(($l + $n)) &&\n"> <"\n"> <"\t\ti=$((1 + $i)) || return 1\n"> <"\tdone &&\n"> <"\n"> <"\tsort tree.exp > tree.exp_s &&\n"> <"\n"> <"\tcat input.blob input.commit | git fast-import --export-marks=marks.large &&\n"> <"\tgit ls-tree refs/heads/verify--dump-marks >tree.out &&\n"> <"\ttest_cmp tree.exp_s tree.out &&\n"> <"\ttest_cmp marks.exp marks.large\n"> ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid blob sha1">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tmark :1\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcorrupt\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/master\n"> <"\tM 755 0000000000000000000000000000000000000001 zero1\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"rm -f .git/objects/pack_* .git/objects/index_*\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"B: accept branch name \"TEMP_TAG\"">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit TEMP_TAG\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\ttag base\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/master\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"rm -f .git/TEMP_TAG\n"> <"\t\tgit gc\n"> <"\t\tgit prune\" &&\n"> <"\tgit fast-import <"\ttest -f .git/TEMP_TAG &&\n"> <"\ttest $(git rev-parse master) = $(git rev-parse TEMP_TAG^)\n"> ) } ) (C {(test_expect_success)} {(SQ <"B: accept empty committer">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/empty-committer-1\n"> <"\tcommitter <> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/empty-committer-1\n"> <"\t\tgit gc\n"> <"\t\tgit prune\" &&\n"> <"\tgit fast-import <"\tout=$(git fsck) &&\n"> <"\techo \"$out\" &&\n"> <"\ttest -z \"$out\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"B: accept and fixup committer with no name">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/empty-committer-2\n"> <"\tcommitter $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/empty-committer-2\n"> <"\t\tgit gc\n"> <"\t\tgit prune\" &&\n"> <"\tgit fast-import <"\tout=$(git fsck) &&\n"> <"\techo \"$out\" &&\n"> <"\ttest -z \"$out\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid committer (1)">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/invalid-committer\n"> <"\tcommitter Name email> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/invalid-committer\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid committer (2)">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/invalid-committer\n"> <"\tcommitter Name $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/invalid-committer\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid committer (3)">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/invalid-committer\n"> <"\tcommitter Name > $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/invalid-committer\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid committer (4)">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/invalid-committer\n"> <"\tcommitter Name <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/invalid-committer\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"B: fail on invalid committer (5)">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/invalid-committer\n"> <"\tcommitter Name $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tempty commit\n"> <"\tCOMMIT\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/invalid-committer\" &&\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"C: incremental import create pack from stdin">)} { (SQ <"\n"> <"\tnewf=$(echo hi newf | git hash-object -w --stdin) &&\n"> <"\toldf=$(git rev-parse --verify master:file2) &&\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tsecond\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/master\n"> <"\tM 644 $oldf file2/oldf\n"> <"\tM 755 $newf file2/newf\n"> <"\tD file3\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\tgit whatchanged branch\n"> ) } ) (C {(test_expect_success)} {(SQ <"C: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"C: validate reuse existing blob">)} { (SQ <"\n"> <"\ttest $newf = $(git rev-parse --verify branch:file2/newf) &&\n"> <"\ttest $oldf = $(git rev-parse --verify branch:file2/oldf)\n"> ) } ) (C {(test_expect_success)} {(SQ <"C: verify commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tparent $(git rev-parse --verify master^0)\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tsecond\n"> <"\tEOF\n"> <"\n"> <"\tgit cat-file commit branch | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"C: validate rename result">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A\tfile2/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100\tfile2\tfile2/oldf\n" > < "\t:100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D\tfile3\n" > <"\tEOF\n"> <"\tgit diff-tree -M -r master branch >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"D: inline data in commit">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tthird\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 644 inline newdir/interesting\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\tM 755 inline newdir/exec.sh\n"> <"\tdata < <"\t$file6_data\n"> <"\tEOF\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\tgit whatchanged branch\n"> ) } ) (C {(test_expect_success)} {(SQ <"D: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"D: validate new files added">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A\tnewdir/exec.sh\n" > < "\t:000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A\tnewdir/interesting\n" > <"\tEOF\n"> <"\tgit diff-tree -M -r branch^ branch >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"D: verify file5">)} { (SQ <"\n"> <"\techo \"$file5_data\" >expect &&\n"> <"\tgit cat-file blob branch:newdir/interesting >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"D: verify file6">)} { (SQ <"\n"> <"\techo \"$file6_data\" >expect &&\n"> <"\tgit cat-file blob branch:newdir/exec.sh >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"E: rfc2822 date, --date-format=raw">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tauthor $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500\n"> <"\tdata < <"\tRFC 2822 type date\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_must_fail git fast-import --date-format=raw ) } ) (C {(test_expect_success)} {(SQ <"E: rfc2822 date, --date-format=rfc2822">)} {(SQ <"\n"> <"\tgit fast-import --date-format=rfc2822 )} ) (C {(test_expect_success)} {(SQ <"E: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"E: verify commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tauthor $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500\n"> <"\n"> <"\tRFC 2822 type date\n"> <"\tEOF\n"> <"\tgit cat-file commit branch | sed 1,2d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"F: non-fast-forward update skips">)} { (SQ <"\n"> <"\told_branch=$(git rev-parse --verify branch^0) &&\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tlosing things already?\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch~1\n"> <"\n"> <"\treset refs/heads/other\n"> <"\tfrom refs/heads/branch\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_must_fail git fast-import <"\t# branch must remain unaffected\n"> <"\ttest $old_branch = $(git rev-parse --verify branch^0)\n"> ) } ) (C {(test_expect_success)} {(SQ <"F: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"F: verify other commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\ttree $(git rev-parse branch~1^{tree})\n"> <"\tparent $(git rev-parse branch~1)\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tlosing things already?\n"> <"\tEOF\n"> <"\tgit cat-file commit other >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"G: non-fast-forward update forced">)} { (SQ <"\n"> <"\told_branch=$(git rev-parse --verify branch^0) &&\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/branch\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tlosing things already?\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch~1\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import --force ) } ) (C {(test_expect_success)} {(SQ <"G: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"G: branch changed, but logged">)} { (SQ <"\n"> <"\ttest $old_branch != $(git rev-parse --verify branch^0) &&\n"> <"\ttest $old_branch = $(git rev-parse --verify branch@{1})\n"> ) } ) (C {(test_expect_success)} {(SQ <"H: deletall, add 1">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/H\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tthird\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 644 inline i-will-die\n"> <"\tdata < <"\tthis file will never exist.\n"> <"\tEOF\n"> <"\n"> <"\tdeleteall\n"> <"\tM 644 inline h/e/l/lo\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit whatchanged H\n"> ) } ) (C {(test_expect_success)} {(SQ <"H: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"H: validate old files removed, new files added">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D\tfile2/newf\n" > < "\t:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D\tfile2/oldf\n" > < "\t:100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D\tfile4\n" > < "\t:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100\tnewdir/interesting\th/e/l/lo\n" > < "\t:100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D\tnewdir/exec.sh\n" > <"\tEOF\n"> <"\tgit diff-tree -M -r H^ H >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"H: verify file">)} { (SQ <"\n"> <"\techo \"$file5_data\" >expect &&\n"> <"\tgit cat-file blob H:h/e/l/lo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"I: export-pack-edges">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/export-boundary\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\twe have a border. its only 40 characters wide.\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import --export-pack-edges=edges.list ) } ) (C {(test_expect_success)} {(SQ <"I: verify edge list">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t.git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)\n"> <"\tEOF\n"> <"\tsed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"J: reset existing branch creates empty commit">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/J\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcreate J\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch\n"> <"\n"> <"\treset refs/heads/J\n"> <"\n"> <"\tcommit refs/heads/J\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tinitialize J\n"> <"\tCOMMIT\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"J: branch has 1 commit, empty tree">)} { (SQ <"\n"> <"\ttest 1 = $(git rev-list J | wc -l) &&\n"> <"\ttest 0 = $(git ls-tree J | wc -l)\n"> ) } ) (C {(test_expect_success)} {(SQ <"J: tag must fail on empty branch">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\treset refs/heads/J2\n"> <"\n"> <"\ttag wrong_tag\n"> <"\tfrom refs/heads/J2\n"> <"\tdata < <"\tTag branch that was reset.\n"> <"\tEOF\n"> <"\tINPUT_END\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"K: reinit branch with from">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/K\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcreate K\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch\n"> <"\n"> <"\tcommit refs/heads/K\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tredo K\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^1\n"> <"\n"> <"\tINPUT_END\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"K: verify K^1 = branch^1">)} { (SQ <"\n"> <"\ttest $(git rev-parse --verify branch^1) \\\n"> <"\t\t= $(git rev-parse --verify K^1)\n"> ) } ) (C {(test_expect_success)} {(SQ <"L: verify internal tree sorting">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\tsome data\n"> <"\tEOF\n"> <"\n"> <"\tblob\n"> <"\tmark :2\n"> <"\tdata < <"\tother data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/heads/L\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcreate L\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 :1 b.\n"> <"\tM 644 :1 b/other\n"> <"\tM 644 :1 ba\n"> <"\n"> <"\tcommit refs/heads/L\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tupdate L\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 :2 b.\n"> <"\tM 644 :2 b/other\n"> <"\tM 644 :2 ba\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EXPECT_END &&\n"> <"\t:100644 100644 4268632... 55d3a52... M\tb.\n"> <"\t:040000 040000 0ae5cac... 443c768... M\tb\n"> <"\t:100644 100644 4268632... 55d3a52... M\tba\n"> <"\tEXPECT_END\n"> <"\n"> <"\tgit fast-import <"\tgit diff-tree --abbrev --raw L^ L >output &&\n"> <"\ttest_cmp expect output\n"> ) } ) (C {(test_expect_success)} {(SQ <"L: nested tree copy does not corrupt deltas">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\tthe data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/heads/L2\n"> <"\tcommitter C O Mitter 1112912473 -0700\n"> <"\tdata < <"\tinit L2\n"> <"\tCOMMIT\n"> <"\tM 644 :1 a/b/c\n"> <"\tM 644 :1 a/b/d\n"> <"\tM 644 :1 a/e/f\n"> <"\n"> <"\tcommit refs/heads/L2\n"> <"\tcommitter C O Mitter 1112912473 -0700\n"> <"\tdata < <"\tupdate L2\n"> <"\tCOMMIT\n"> <"\tC a g\n"> <"\tC a/e g/b\n"> <"\tM 644 :1 g/b/h\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tg/b/f\n"> <"\tg/b/h\n"> <"\tEOF\n"> <"\n"> <"\ttest_when_finished \"git update-ref -d refs/heads/L2\" &&\n"> <"\tgit fast-import <"\tgit ls-tree L2 g/b/ >tmp &&\n"> <"\tcat tmp | cut -f 2 >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\tgit fsck $(git rev-parse L2)\n"> ) } ) (C {(test_expect_success)} {(SQ <"M: rename file in same subdirectory">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/M1\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tfile rename\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tR file2/newf file2/n.e.w.f\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100\tfile2/newf\tfile2/n.e.w.f\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -M -r M1^ M1 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"M: rename file to new subdirectory">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/M2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tfile rename\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tR file2/newf i/am/new/to/you\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100\tfile2/newf\ti/am/new/to/you\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -M -r M2^ M2 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"M: rename subdirectory to new subdirectory">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/M3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tfile rename\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/M2^0\n"> <"\tR i other/sub\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100\ti/am/new/to/you\tother/sub/am/new/to/you\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -M -r M3^ M3 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"M: rename root to subdirectory">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/M4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\trename root\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/M2^0\n"> <"\tR \"\" sub\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100\tfile2/oldf\tsub/file2/oldf\n" > < "\t:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100\tfile4\tsub/file4\n" > < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100\ti/am/new/to/you\tsub/i/am/new/to/you\n" > < "\t:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100\tnewdir/exec.sh\tsub/newdir/exec.sh\n" > < "\t:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100\tnewdir/interesting\tsub/newdir/interesting\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -M -r M4^ M4 >actual &&\n"> <"\tcat actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy file in same subdirectory">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N1\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tfile copy\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tC file2/newf file2/n.e.w.f\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\tfile2/n.e.w.f\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r N1^ N1 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy then modify subdirectory">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tclean directory copy\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tC file2 file3\n"> <"\n"> <"\tcommit refs/heads/N2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tmodify directory copy\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 inline file3/file5\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100\tnewdir/interesting\tfile3/file5\n" > < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\tfile3/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100\tfile2/oldf\tfile3/oldf\n" > <"\tEOF\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy dirty subdirectory">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tdirty directory copy\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 644 inline file2/file5\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\tC file2 file3\n"> <"\tD file2/file5\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\ttest $(git rev-parse N2^{tree}) = $(git rev-parse N3^{tree})\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy directory by id">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\tfile3/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100\tfile2/oldf\tfile3/oldf\n" > <"\tEOF\n"> <"\tsubdir=$(git rev-parse refs/heads/branch^0:file2) &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy by tree hash\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 040000 $subdir file3\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r N4^ N4 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(PIPE)} {(SQ <"N: read and copy directory">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\tfile3/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100\tfile2/oldf\tfile3/oldf\n" > <"\tEOF\n"> <"\tgit update-ref -d refs/heads/N4 &&\n"> <"\trm -f backflow &&\n"> <"\tmkfifo backflow &&\n"> <"\t(\n"> <"\t\texec <"\t\tcat <<-EOF &&\n"> <"\t\tcommit refs/heads/N4\n"> <"\t\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t\tdata < <"\t\tcopy by tree hash, part 2\n"> <"\t\tCOMMIT\n"> <"\n"> <"\t\tfrom refs/heads/branch^0\n"> <"\t\tls \"file2\"\n"> <"\t\tEOF\n"> <"\t\tread mode type tree filename &&\n"> <"\t\techo \"M 040000 $tree file3\"\n"> <"\t) |\n"> <"\tgit fast-import --cat-blob-fd=3 3>backflow &&\n"> <"\tgit diff-tree -C --find-copies-harder -r N4^ N4 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(PIPE)} {(SQ <"N: empty directory reads as missing">)} { (SQ <"\n"> <"\tcat <<-\\EOF >expect &&\n"> <"\tOBJNAME\n"> <"\t:000000 100644 OBJNAME OBJNAME A\tunrelated\n"> <"\tEOF\n"> <"\techo \"missing src\" >expect.response &&\n"> <"\tgit update-ref -d refs/heads/read-empty &&\n"> <"\trm -f backflow &&\n"> <"\tmkfifo backflow &&\n"> <"\t(\n"> <"\t\texec <"\t\tcat <<-EOF &&\n"> <"\t\tcommit refs/heads/read-empty\n"> <"\t\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t\tdata < <"\t\tread \"empty\" (missing) directory\n"> <"\t\tCOMMIT\n"> <"\n"> <"\t\tM 100644 inline src/greeting\n"> <"\t\tdata < <"\t\thello\n"> <"\t\tBLOB\n"> <"\t\tC src/greeting dst1/non-greeting\n"> <"\t\tC src/greeting unrelated\n"> <"\t\t# leave behind \"empty\" src directory\n"> <"\t\tD src/greeting\n"> <"\t\tls \"src\"\n"> <"\t\tEOF\n"> <"\t\tread -r line &&\n"> <"\t\tprintf \"%s\\n\" \"$line\" >response &&\n"> <"\t\tcat <<-\\EOF\n"> <"\t\tD dst1\n"> <"\t\tD dst2\n"> <"\t\tEOF\n"> <"\t) |\n"> <"\tgit fast-import --cat-blob-fd=3 3>backflow &&\n"> <"\ttest_cmp expect.response response &&\n"> <"\tgit rev-list read-empty |\n"> <"\tgit diff-tree -r --root --stdin |\n"> <"\tsed \"s/$_x40/OBJNAME/g\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy root directory by tree hash">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> < "\t:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D\tfile3/newf\n" > < "\t:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D\tfile3/oldf\n" > <"\tEOF\n"> <"\troot=$(git rev-parse refs/heads/branch^0^{tree}) &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N6\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy root directory by tree hash\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 040000 $root \"\"\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r N4 N6 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy root by path">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\toldroot/file2/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100\tfile2/oldf\toldroot/file2/oldf\n" > < "\t:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100\tfile4\toldroot/file4\n" > < "\t:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100\tnewdir/exec.sh\toldroot/newdir/exec.sh\n" > < "\t:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100\tnewdir/interesting\toldroot/newdir/interesting\n" > <"\tEOF\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N-copy-root-path\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy root directory by (empty) path\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tC \"\" oldroot\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: delete directory by copying">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tOBJID\n"> <"\t:100644 000000 OBJID OBJID D\tfoo/bar/qux\n"> <"\tOBJID\n"> <"\t:000000 100644 OBJID OBJID A\tfoo/bar/baz\n"> <"\t:000000 100644 OBJID OBJID A\tfoo/bar/qux\n"> <"\tEOF\n"> <"\tempty_tree=$(git mktree <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N-delete\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcollect data to be deleted\n"> <"\tCOMMIT\n"> <"\n"> <"\tdeleteall\n"> <"\tM 100644 inline foo/bar/baz\n"> <"\tdata < <"\thello\n"> <"\tDATA_END\n"> <"\tC \"foo/bar/baz\" \"foo/bar/qux\"\n"> <"\tC \"foo/bar/baz\" \"foo/bar/quux/1\"\n"> <"\tC \"foo/bar/baz\" \"foo/bar/quuux\"\n"> <"\tM 040000 $empty_tree foo/bar/quux\n"> <"\tM 040000 $empty_tree foo/bar/quuux\n"> <"\n"> <"\tcommit refs/heads/N-delete\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tdelete subdirectory\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 040000 $empty_tree foo/bar/qux\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit rev-list N-delete |\n"> <"\t\tgit diff-tree -r --stdin --root --always |\n"> <"\t\tsed -e \"s/$_x40/OBJID/g\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: modify copied tree">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> < "\t:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100\tnewdir/interesting\tfile3/file5\n" > < "\t:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100\tfile2/newf\tfile3/newf\n" > < "\t:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100\tfile2/oldf\tfile3/oldf\n" > <"\tEOF\n"> <"\tsubdir=$(git rev-parse refs/heads/branch^0:file2) &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N5\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy by tree hash\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 040000 $subdir file3\n"> <"\n"> <"\tcommit refs/heads/N5\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tmodify directory copy\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 inline file3/file5\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: reject foo/ syntax">)} { (SQ <"\n"> <"\tsubdir=$(git rev-parse refs/heads/branch^0:file2) &&\n"> <"\ttest_must_fail git fast-import <<-INPUT_END\n"> <"\tcommit refs/heads/N5B\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy with invalid syntax\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 040000 $subdir file3/\n"> <"\tINPUT_END\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: reject foo/ syntax in copy source">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import <<-INPUT_END\n"> <"\tcommit refs/heads/N5C\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy with invalid syntax\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tC file2/ file3\n"> <"\tINPUT_END\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: reject foo/ syntax in rename source">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import <<-INPUT_END\n"> <"\tcommit refs/heads/N5D\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\trename with invalid syntax\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tR file2/ file3\n"> <"\tINPUT_END\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: reject foo/ syntax in ls argument">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import <<-INPUT_END\n"> <"\tcommit refs/heads/N5E\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy with invalid syntax\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/branch^0\n"> <"\tls \"file2/\"\n"> <"\tINPUT_END\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: copy to root by id and modify">)} { (SQ <"\n"> <"\techo \"hello, world\" >expect.foo &&\n"> <"\techo hello >expect.bar &&\n"> <"\tgit fast-import <<-SETUP_END &&\n"> <"\tcommit refs/heads/N7\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\thello, tree\n"> <"\tCOMMIT\n"> <"\n"> <"\tdeleteall\n"> <"\tM 644 inline foo/bar\n"> <"\tdata < <"\thello\n"> <"\tEOF\n"> <"\tSETUP_END\n"> <"\n"> <"\ttree=$(git rev-parse --verify N7:) &&\n"> <"\tgit fast-import <<-INPUT_END &&\n"> <"\tcommit refs/heads/N8\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy to root by id and modify\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 040000 $tree \"\"\n"> <"\tM 644 inline foo/foo\n"> <"\tdata < <"\thello, world\n"> <"\tEOF\n"> <"\tINPUT_END\n"> <"\tgit show N8:foo/foo >actual.foo &&\n"> <"\tgit show N8:foo/bar >actual.bar &&\n"> <"\ttest_cmp expect.foo actual.foo &&\n"> <"\ttest_cmp expect.bar actual.bar\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: extract subtree">)} { (SQ <"\n"> <"\tbranch=$(git rev-parse --verify refs/heads/branch^{tree}) &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/N9\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\textract subtree branch:newdir\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 040000 $branch \"\"\n"> <"\tC \"newdir\" \"\"\n"> <"\tINPUT_END\n"> <"\tgit fast-import <"\tgit diff --exit-code branch:newdir N9\n"> ) } ) (C {(test_expect_success)} {(SQ <"N: modify subtree, extract it, and modify again">)} { (SQ <"\n"> <"\techo hello >expect.baz &&\n"> <"\techo hello, world >expect.qux &&\n"> <"\tgit fast-import <<-SETUP_END &&\n"> <"\tcommit refs/heads/N10\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\thello, tree\n"> <"\tCOMMIT\n"> <"\n"> <"\tdeleteall\n"> <"\tM 644 inline foo/bar/baz\n"> <"\tdata < <"\thello\n"> <"\tEOF\n"> <"\tSETUP_END\n"> <"\n"> <"\ttree=$(git rev-parse --verify N10:) &&\n"> <"\tgit fast-import <<-INPUT_END &&\n"> <"\tcommit refs/heads/N11\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcopy to root by id and modify\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 040000 $tree \"\"\n"> <"\tM 100644 inline foo/bar/qux\n"> <"\tdata < <"\thello, world\n"> <"\tEOF\n"> <"\tR \"foo\" \"\"\n"> <"\tC \"bar/qux\" \"bar/quux\"\n"> <"\tINPUT_END\n"> <"\tgit show N11:bar/baz >actual.baz &&\n"> <"\tgit show N11:bar/qux >actual.qux &&\n"> <"\tgit show N11:bar/quux >actual.quux &&\n"> <"\ttest_cmp expect.baz actual.baz &&\n"> <"\ttest_cmp expect.qux actual.qux &&\n"> <"\ttest_cmp expect.qux actual.quux"> ) } ) (C {(test_expect_success)} {(SQ <"O: comments are all skipped">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\t#we will\n"> <"\tcommit refs/heads/O1\n"> <"\t# -- ignore all of this text\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t# $GIT_COMMITTER_NAME has inserted here for his benefit.\n"> <"\tdata < <"\tdirty directory copy\n"> <"\tCOMMIT\n"> <"\n"> <"\t# do not forget the import blank line!\n"> <"\t#\n"> <"\t# yes, we started from our usual base of branch^0.\n"> <"\t# i like branch^0.\n"> <"\tfrom refs/heads/branch^0\n"> <"\t# and we need to reuse file2/file5 from N3 above.\n"> <"\tM 644 inline file2/file5\n"> <"\t# otherwise the tree will be different\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\t# do not forget to copy file2 to file3\n"> <"\tC file2 file3\n"> <"\t#\n"> <"\t# or to delete file5 from file2.\n"> <"\tD file2/file5\n"> <"\t# are we done yet?\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\ttest $(git rev-parse N3) = $(git rev-parse O1)\n"> ) } ) (C {(test_expect_success)} {(SQ <"O: blank lines not necessary after data commands">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/O2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tdirty directory copy\n"> <"\tCOMMIT\n"> <"\tfrom refs/heads/branch^0\n"> <"\tM 644 inline file2/file5\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\tC file2 file3\n"> <"\tD file2/file5\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\ttest $(git rev-parse N3) = $(git rev-parse O2)\n"> ) } ) (C {(test_expect_success)} {(SQ <"O: repack before next test">)} {(SQ <"\n"> <"\tgit repack -a -d\n">)} ) (C {(test_expect_success)} {(SQ <"O: blank lines not necessary after other commands">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/O3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzstring\n"> <"\tCOMMIT\n"> <"\tcommit refs/heads/O3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzof\n"> <"\tCOMMIT\n"> <"\tcheckpoint\n"> <"\tcommit refs/heads/O3\n"> <"\tmark :5\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzempty\n"> <"\tCOMMIT\n"> <"\tcheckpoint\n"> <"\tcommit refs/heads/O3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzcommits\n"> <"\tCOMMIT\n"> <"\treset refs/tags/O3-2nd\n"> <"\tfrom :5\n"> <"\treset refs/tags/O3-3rd\n"> <"\tfrom :5\n"> <"\tINPUT_END\n"> <"\n"> <"\tcat >expect <<-INPUT_END &&\n"> <"\tstring\n"> <"\tof\n"> <"\tempty\n"> <"\tcommits\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\ttest 8 = $(find .git/objects/pack -type f | wc -l) &&\n"> <"\ttest $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&\n"> <"\tgit log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"O: progress outputs as requested by input">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/O4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzstring\n"> <"\tCOMMIT\n"> <"\tcommit refs/heads/O4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzof\n"> <"\tCOMMIT\n"> <"\tprogress Two commits down, 2 to go!\n"> <"\tcommit refs/heads/O4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzempty\n"> <"\tCOMMIT\n"> <"\tprogress Three commits down, 1 to go!\n"> <"\tcommit refs/heads/O4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tzcommits\n"> <"\tCOMMIT\n"> <"\tprogress done!\n"> <"\tINPUT_END\n"> <"\tgit fast-import actual &&\n"> <"\tgrep \"progress \" expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"P: superproject & submodule mix">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata 10\n"> <"\ttest file\n"> <"\n"> <"\treset refs/heads/sub\n"> <"\tcommit refs/heads/sub\n"> <"\tmark :2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 12\n"> <"\tsub_initial\n"> <"\tM 100644 :1 file\n"> <"\n"> <"\tblob\n"> <"\tmark :3\n"> <"\tdata < <"\t[submodule \"sub\"]\n"> <"\t\tpath = sub\n"> <"\t\turl = \"$(pwd)/sub\"\n"> <"\tDATAEND\n"> <"\n"> <"\tcommit refs/heads/subuse1\n"> <"\tmark :4\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 8\n"> <"\tinitial\n"> <"\tfrom refs/heads/master\n"> <"\tM 100644 :3 .gitmodules\n"> <"\tM 160000 :2 sub\n"> <"\n"> <"\tblob\n"> <"\tmark :5\n"> <"\tdata 20\n"> <"\ttest file\n"> <"\tmore data\n"> <"\n"> <"\tcommit refs/heads/sub\n"> <"\tmark :6\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 11\n"> <"\tsub_second\n"> <"\tfrom :2\n"> <"\tM 100644 :5 file\n"> <"\n"> <"\tcommit refs/heads/subuse1\n"> <"\tmark :7\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 7\n"> <"\tsecond\n"> <"\tfrom :4\n"> <"\tM 160000 :6 sub\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\tgit checkout subuse1 &&\n"> <"\trm -rf sub &&\n"> <"\tmkdir sub &&\n"> <"\t(\n"> <"\t\tcd sub &&\n"> <"\t\tgit init &&\n"> <"\t\tgit fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&\n"> <"\t\tgit checkout master\n"> <"\t) &&\n"> <"\tgit submodule init &&\n"> <"\tgit submodule update\n"> ) } ) (C {(test_expect_success)} {(SQ <"P: verbatim SHA gitlinks">)} { (SQ <"\n"> <"\tSUBLAST=$(git rev-parse --verify sub) &&\n"> <"\tSUBPREV=$(git rev-parse --verify sub^) &&\n"> <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\t[submodule \"sub\"]\n"> <"\t\tpath = sub\n"> <"\t\turl = \"$(pwd)/sub\"\n"> <"\tDATAEND\n"> <"\n"> <"\tcommit refs/heads/subuse2\n"> <"\tmark :2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 8\n"> <"\tinitial\n"> <"\tfrom refs/heads/master\n"> <"\tM 100644 :1 .gitmodules\n"> <"\tM 160000 $SUBPREV sub\n"> <"\n"> <"\tcommit refs/heads/subuse2\n"> <"\tmark :3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata 7\n"> <"\tsecond\n"> <"\tfrom :2\n"> <"\tM 160000 $SUBLAST sub\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit branch -D sub &&\n"> <"\tgit gc &&\n"> <"\tgit prune &&\n"> <"\tgit fast-import <"\ttest $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)\n"> ) } ) (C {(test_expect_success)} {(SQ <"P: fail on inline gitlink">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/subuse3\n"> <"\tmark :1\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcorrupt\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/subuse2\n"> <"\tM 160000 inline sub\n"> <"\tdata < <"\t$SUBPREV\n"> <"\tDATA\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"P: fail on blob mark in gitlink">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\t$SUBPREV\n"> <"\tDATA\n"> <"\n"> <"\tcommit refs/heads/subuse3\n"> <"\tmark :2\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcorrupt\n"> <"\tCOMMIT\n"> <"\n"> <"\tfrom refs/heads/subuse2\n"> <"\tM 160000 :1 sub\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"Q: commit notes">)} { (SQ <"\n"> <"\tnote1_data=\"The first note for the first commit\" &&\n"> <"\tnote2_data=\"The first note for the second commit\" &&\n"> <"\tnote3_data=\"The first note for the third commit\" &&\n"> <"\tnote1b_data=\"The second note for the first commit\" &&\n"> <"\tnote1c_data=\"The third note for the first commit\" &&\n"> <"\tnote2b_data=\"The second note for the second commit\" &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tblob\n"> <"\tmark :2\n"> <"\tdata < <"\t$file2_data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/heads/notes-test\n"> <"\tmark :3\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tfirst (:3)\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 :2 file2\n"> <"\n"> <"\tblob\n"> <"\tmark :4\n"> <"\tdata $file4_len\n"> <"\t$file4_data\n"> <"\tcommit refs/heads/notes-test\n"> <"\tmark :5\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tsecond (:5)\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 :4 file4\n"> <"\n"> <"\tcommit refs/heads/notes-test\n"> <"\tmark :6\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tthird (:6)\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 inline file5\n"> <"\tdata < <"\t$file5_data\n"> <"\tEOF\n"> <"\n"> <"\tM 755 inline file6\n"> <"\tdata < <"\t$file6_data\n"> <"\tEOF\n"> <"\n"> <"\tblob\n"> <"\tmark :7\n"> <"\tdata < <"\t$note1_data\n"> <"\tEOF\n"> <"\n"> <"\tblob\n"> <"\tmark :8\n"> <"\tdata < <"\t$note2_data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/notes/foobar\n"> <"\tmark :9\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tnotes (:9)\n"> <"\tCOMMIT\n"> <"\n"> <"\tN :7 :3\n"> <"\tN :8 :5\n"> <"\tN inline :6\n"> <"\tdata < <"\t$note3_data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/notes/foobar\n"> <"\tmark :10\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tnotes (:10)\n"> <"\tCOMMIT\n"> <"\n"> <"\tN inline :3\n"> <"\tdata < <"\t$note1b_data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/notes/foobar2\n"> <"\tmark :11\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tnotes (:11)\n"> <"\tCOMMIT\n"> <"\n"> <"\tN inline :3\n"> <"\tdata < <"\t$note1c_data\n"> <"\tEOF\n"> <"\n"> <"\tcommit refs/notes/foobar\n"> <"\tmark :12\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tnotes (:12)\n"> <"\tCOMMIT\n"> <"\n"> <"\tdeleteall\n"> <"\tN inline :5\n"> <"\tdata < <"\t$note2b_data\n"> <"\tEOF\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import <"\tgit whatchanged notes-test\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify pack">)} {(SQ <"\n"> <"\tverify_packs\n">)}) (C {(test_expect_success)} {(SQ <"Q: verify first commit">)} { (SQ <"\n"> <"\tcommit1=$(git rev-parse notes-test~2) &&\n"> <"\tcommit2=$(git rev-parse notes-test^) &&\n"> <"\tcommit3=$(git rev-parse notes-test) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tfirst (:3)\n"> <"\tEOF\n"> <"\tgit cat-file commit notes-test~2 | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify second commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tparent $commit1\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tsecond (:5)\n"> <"\tEOF\n"> <"\tgit cat-file commit notes-test^ | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify third commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tparent $commit2\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tthird (:6)\n"> <"\tEOF\n"> <"\tgit cat-file commit notes-test | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first notes commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tnotes (:9)\n"> <"\tEOF\n"> <"\tgit cat-file commit refs/notes/foobar~2 | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first notes tree">)} { (SQ <"\n"> <"\tcat >expect.unsorted <<-EOF &&\n"> <"\t100644 blob $commit1\n"> <"\t100644 blob $commit2\n"> <"\t100644 blob $commit3\n"> <"\tEOF\n"> <"\tcat expect.unsorted | sort >expect &&\n"> <"\tgit cat-file -p refs/notes/foobar~2^{tree} | sed \"s/ [0-9a-f]*\t/ /\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first note for first commit">)} { (SQ <"\n"> <"\techo \"$note1_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar~2:$commit1 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first note for second commit">)} { (SQ <"\n"> <"\techo \"$note2_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar~2:$commit2 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first note for third commit">)} { (SQ <"\n"> <"\techo \"$note3_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar~2:$commit3 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify second notes commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tparent $(git rev-parse --verify refs/notes/foobar~2)\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tnotes (:10)\n"> <"\tEOF\n"> <"\tgit cat-file commit refs/notes/foobar^ | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify second notes tree">)} { (SQ <"\n"> <"\tcat >expect.unsorted <<-EOF &&\n"> <"\t100644 blob $commit1\n"> <"\t100644 blob $commit2\n"> <"\t100644 blob $commit3\n"> <"\tEOF\n"> <"\tcat expect.unsorted | sort >expect &&\n"> <"\tgit cat-file -p refs/notes/foobar^^{tree} | sed \"s/ [0-9a-f]*\t/ /\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify second note for first commit">)} { (SQ <"\n"> <"\techo \"$note1b_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar^:$commit1 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first note for second commit">)} { (SQ <"\n"> <"\techo \"$note2_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar^:$commit2 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify first note for third commit">)} { (SQ <"\n"> <"\techo \"$note3_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar^:$commit3 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify third notes commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tnotes (:11)\n"> <"\tEOF\n"> <"\tgit cat-file commit refs/notes/foobar2 | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify third notes tree">)} { (SQ <"\n"> <"\tcat >expect.unsorted <<-EOF &&\n"> <"\t100644 blob $commit1\n"> <"\tEOF\n"> <"\tcat expect.unsorted | sort >expect &&\n"> <"\tgit cat-file -p refs/notes/foobar2^{tree} | sed \"s/ [0-9a-f]*\t/ /\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify third note for first commit">)} { (SQ <"\n"> <"\techo \"$note1c_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar2:$commit1 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify fourth notes commit">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\tparent $(git rev-parse --verify refs/notes/foobar^)\n"> <"\tauthor $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\n"> <"\tnotes (:12)\n"> <"\tEOF\n"> <"\tgit cat-file commit refs/notes/foobar | sed 1d >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify fourth notes tree">)} { (SQ <"\n"> <"\tcat >expect.unsorted <<-EOF &&\n"> <"\t100644 blob $commit2\n"> <"\tEOF\n"> <"\tcat expect.unsorted | sort >expect &&\n"> <"\tgit cat-file -p refs/notes/foobar^{tree} | sed \"s/ [0-9a-f]*\t/ /\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: verify second note for second commit">)} { (SQ <"\n"> <"\techo \"$note2b_data\" >expect &&\n"> <"\tgit cat-file blob refs/notes/foobar:$commit2 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"Q: deny note on empty branch">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\treset refs/heads/Q0\n"> <"\n"> <"\tcommit refs/heads/note-Q0\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tNote for an empty branch.\n"> <"\tCOMMIT\n"> <"\n"> <"\tN inline refs/heads/Q0\n"> <"\tdata < <"\tsome note\n"> <"\tNOTE\n"> <"\tEOF\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: abort on unsupported feature">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature no-such-feature-exists\n"> <"\tEOF\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: supported feature is accepted">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature date-format=now\n"> <"\tEOF\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: abort on receiving feature after data command">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tblob\n"> <"\tdata 3\n"> <"\thi\n"> <"\tfeature date-format=now\n"> <"\tEOF\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: only one import-marks feature allowed per stream">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature import-marks=git.marks\n"> <"\tfeature import-marks=git2.marks\n"> <"\tEOF\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: export-marks feature results in a marks file being created">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature export-marks=git.marks\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\n"> <"\tcat input | git fast-import &&\n"> <"\tgrep :1 git.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: export-marks options can be overridden by commandline options">)} { (SQ <"\n"> <"\tcat input | git fast-import --export-marks=other.marks &&\n"> <"\tgrep :1 other.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: catch typo in marks file name">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=nonexistent.marks <"\techo \"feature import-marks=nonexistent.marks\" |\n"> <"\ttest_must_fail git fast-import\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: import and output marks can be the same file">)} { (SQ <"\n"> <"\trm -f io.marks &&\n"> <"\tblob=$(echo hi | git hash-object --stdin) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t:1 $blob\n"> <"\t:2 $blob\n"> <"\tEOF\n"> <"\tgit fast-import --export-marks=io.marks <<-\\EOF &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\tgit fast-import --import-marks=io.marks --export-marks=io.marks <<-\\EOF &&\n"> <"\tblob\n"> <"\tmark :2\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: --import-marks=foo --output-marks=foo to create foo fails">)} { (SQ <"\n"> <"\trm -f io.marks &&\n"> < "\ttest_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\\EOF\n" > <"\tblob\n"> <"\tmark :1\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: --import-marks-if-exists">)} { (SQ <"\n"> <"\trm -f io.marks &&\n"> <"\tblob=$(echo hi | git hash-object --stdin) &&\n"> <"\techo \":1 $blob\" >expect &&\n"> <"\tgit fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\\EOF &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: feature import-marks-if-exists">)} { (SQ <"\n"> <"\trm -f io.marks &&\n"> <"\t>expect &&\n"> <"\n"> <"\tgit fast-import --export-marks=io.marks <<-\\EOF &&\n"> <"\tfeature import-marks-if-exists=not_io.marks\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks &&\n"> <"\n"> <"\tblob=$(echo hi | git hash-object --stdin) &&\n"> <"\n"> <"\techo \":1 $blob\" >io.marks &&\n"> <"\techo \":1 $blob\" >expect &&\n"> <"\techo \":2 $blob\" >>expect &&\n"> <"\n"> <"\tgit fast-import --export-marks=io.marks <<-\\EOF &&\n"> <"\tfeature import-marks-if-exists=io.marks\n"> <"\tblob\n"> <"\tmark :2\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks &&\n"> <"\n"> <"\techo \":3 $blob\" >>expect &&\n"> <"\n"> <"\tgit fast-import --import-marks=io.marks \\\n"> <"\t\t\t--export-marks=io.marks <<-\\EOF &&\n"> <"\tfeature import-marks-if-exists=not_io.marks\n"> <"\tblob\n"> <"\tmark :3\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks &&\n"> <"\n"> <"\t>expect &&\n"> <"\n"> <"\tgit fast-import --import-marks-if-exists=not_io.marks \\\n"> <"\t\t\t--export-marks=io.marks <<-\\EOF &&\n"> <"\tfeature import-marks-if-exists=io.marks\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: import to output marks works without any content">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature import-marks=marks.out\n"> <"\tfeature export-marks=marks.new\n"> <"\tEOF\n"> <"\n"> <"\tcat input | git fast-import &&\n"> <"\ttest_cmp marks.out marks.new\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: import marks prefers commandline marks file over the stream">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature import-marks=nonexistent.marks\n"> <"\tfeature export-marks=marks.new\n"> <"\tEOF\n"> <"\n"> <"\tcat input | git fast-import --import-marks=marks.out &&\n"> <"\ttest_cmp marks.out marks.new\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: multiple --import-marks= should be honoured">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature import-marks=nonexistent.marks\n"> <"\tfeature export-marks=combined.marks\n"> <"\tEOF\n"> <"\n"> <"\thead -n2 marks.out > one.marks &&\n"> <"\ttail -n +3 marks.out > two.marks &&\n"> <"\tgit fast-import --import-marks=one.marks --import-marks=two.marks <"\ttest_cmp marks.out combined.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: feature relative-marks should be honoured">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature relative-marks\n"> <"\tfeature import-marks=relative.in\n"> <"\tfeature export-marks=relative.out\n"> <"\tEOF\n"> <"\n"> <"\tmkdir -p .git/info/fast-import/ &&\n"> <"\tcp marks.new .git/info/fast-import/relative.in &&\n"> <"\tgit fast-import <"\ttest_cmp marks.new .git/info/fast-import/relative.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: feature no-relative-marks should be honoured">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\tfeature relative-marks\n"> <"\tfeature import-marks=relative.in\n"> <"\tfeature no-relative-marks\n"> <"\tfeature export-marks=non-relative.out\n"> <"\tEOF\n"> <"\n"> <"\tgit fast-import <"\ttest_cmp marks.new non-relative.out\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: feature ls supported">)} {(SQ <"\n"> <"\techo \"feature ls\" |\n"> <"\tgit fast-import\n">)} ) (C {(test_expect_success)} {(SQ <"R: feature cat-blob supported">)} {(SQ <"\n"> <"\techo \"feature cat-blob\" |\n"> <"\tgit fast-import\n">)} ) (C {(test_expect_success)} {(SQ <"R: cat-blob-fd must be a nonnegative integer">)} {(SQ <"\n"> <"\ttest_must_fail git fast-import --cat-blob-fd=-1 )} ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"R: print old blob">)} { (SQ <"\n"> <"\tblob=$(echo \"yes it can\" | git hash-object -w --stdin) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t${blob} blob 11\n"> <"\tyes it can\n"> <"\n"> <"\tEOF\n"> <"\techo \"cat-blob $blob\" |\n"> <"\tgit fast-import --cat-blob-fd=6 6>actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"R: in-stream cat-blob-fd not respected">)} { (SQ <"\n"> <"\techo hello >greeting &&\n"> <"\tblob=$(git hash-object -w greeting) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t${blob} blob 6\n"> <"\thello\n"> <"\n"> <"\tEOF\n"> <"\tgit fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&\n"> <"\tcat-blob $blob\n"> <"\tEOF\n"> <"\ttest_cmp expect actual.3 &&\n"> <"\ttest_must_be_empty actual.1 &&\n"> <"\tgit fast-import 3>actual.3 >actual.1 <<-EOF &&\n"> <"\toption cat-blob-fd=3\n"> <"\tcat-blob $blob\n"> <"\tEOF\n"> <"\ttest_must_be_empty actual.3 &&\n"> <"\ttest_cmp expect actual.1\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"R: print mark for new blob">)} { (SQ <"\n"> <"\techo \"effluentish\" | git hash-object --stdin >expect &&\n"> <"\tgit fast-import --cat-blob-fd=6 6>actual <<-\\EOF &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\teffluentish\n"> <"\tBLOB_END\n"> <"\tget-mark :1\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"R: print new blob">)} { (SQ <"\n"> <"\tblob=$(echo \"yep yep yep\" | git hash-object --stdin) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t${blob} blob 12\n"> <"\tyep yep yep\n"> <"\n"> <"\tEOF\n"> <"\tgit fast-import --cat-blob-fd=6 6>actual <<-\\EOF &&\n"> <"\tblob\n"> <"\tmark :1\n"> <"\tdata < <"\tyep yep yep\n"> <"\tBLOB_END\n"> <"\tcat-blob :1\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(KW_Bang "!") (MINGW)} {(SQ <"R: print new blob by sha1">)} { (SQ <"\n"> <"\tblob=$(echo \"a new blob named by sha1\" | git hash-object --stdin) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t${blob} blob 25\n"> <"\ta new blob named by sha1\n"> <"\n"> <"\tEOF\n"> <"\tgit fast-import --cat-blob-fd=6 6>actual <<-EOF &&\n"> <"\tblob\n"> <"\tdata < <"\ta new blob named by sha1\n"> <"\tBLOB_END\n"> <"\tcat-blob $blob\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup: big file">)} { (SQ <"\n"> <"\t(\n"> <"\t\techo \"the quick brown fox jumps over the lazy dog\" >big &&\n"> <"\t\tfor i in 1 2 3\n"> <"\t\tdo\n"> <"\t\t\tcat big big big big >bigger &&\n"> <"\t\t\tcat bigger bigger bigger bigger >big ||\n"> <"\t\t\texit\n"> <"\t\tdone\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: print two blobs to stdout">)} { (SQ <"\n"> <"\tblob1=$(git hash-object big) &&\n"> <"\tblob1_len=$(wc -c <"\tblob2=$(echo hello | git hash-object --stdin) &&\n"> <"\t{\n"> <"\t\techo ${blob1} blob $blob1_len &&\n"> <"\t\tcat big &&\n"> <"\t\tcat <<-EOF\n"> <"\n"> <"\t\t${blob2} blob 6\n"> <"\t\thello\n"> <"\n"> <"\t\tEOF\n"> <"\t} >expect &&\n"> <"\t{\n"> <"\t\tcat <<-\\END_PART1 &&\n"> <"\t\t\tblob\n"> <"\t\t\tmark :1\n"> <"\t\t\tdata < <"\t\tEND_PART1\n"> <"\t\tcat big &&\n"> <"\t\tcat <<-\\EOF\n"> <"\t\t\tdata_end\n"> <"\t\t\tblob\n"> <"\t\t\tmark :2\n"> <"\t\t\tdata < <"\t\t\thello\n"> <"\t\t\tdata_end\n"> <"\t\t\tcat-blob :1\n"> <"\t\t\tcat-blob :2\n"> <"\t\tEOF\n"> <"\t} |\n"> <"\tgit fast-import >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(PIPE)} {(SQ <"R: copy using cat-file">)} { (SQ <"\n"> <"\texpect_id=$(git hash-object big) &&\n"> <"\texpect_len=$(wc -c <"\techo $expect_id blob $expect_len >expect.response &&\n"> <"\n"> <"\trm -f blobs &&\n"> <"\tcat >frontend <<-\\FRONTEND_END &&\n"> <"\t#!/bin/sh\n"> <"\tFRONTEND_END\n"> <"\n"> <"\tmkfifo blobs &&\n"> <"\t(\n"> <"\t\texport GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&\n"> <"\t\tcat <<-\\EOF &&\n"> <"\t\tfeature cat-blob\n"> <"\t\tblob\n"> <"\t\tmark :1\n"> <"\t\tdata < <"\t\tEOF\n"> <"\t\tcat big &&\n"> <"\t\tcat <<-\\EOF &&\n"> <"\t\tBLOB\n"> <"\t\tcat-blob :1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tread blob_id type size <&3 &&\n"> <"\t\techo \"$blob_id $type $size\" >response &&\n"> <"\t\ttest_copy_bytes $size >blob <&3 &&\n"> <"\t\tread newline <&3 &&\n"> <"\n"> <"\t\tcat <<-EOF &&\n"> <"\t\tcommit refs/heads/copied\n"> <"\t\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t\tdata < <"\t\tcopy big file as file3\n"> <"\t\tCOMMIT\n"> <"\t\tM 644 inline file3\n"> <"\t\tdata < <"\t\tEOF\n"> <"\t\tcat blob &&\n"> <"\t\techo BLOB\n"> <"\t) 3 <"\tgit fast-import --cat-blob-fd=3 3>blobs &&\n"> <"\tgit show copied:file3 >actual &&\n"> <"\ttest_cmp expect.response response &&\n"> <"\ttest_cmp big actual\n"> ) } ) (C {(test_expect_success)} {(PIPE)} {(SQ <"R: print blob mid-commit">)} { (SQ <"\n"> <"\trm -f blobs &&\n"> <"\techo \"A blob from _before_ the commit.\" >expect &&\n"> <"\tmkfifo blobs &&\n"> <"\t(\n"> <"\t\texec 3 <"\t\tcat <<-EOF &&\n"> <"\t\tfeature cat-blob\n"> <"\t\tblob\n"> <"\t\tmark :1\n"> <"\t\tdata < <"\t\tA blob from _before_ the commit.\n"> <"\t\tBLOB\n"> <"\t\tcommit refs/heads/temporary\n"> <"\t\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t\tdata < <"\t\tEmpty commit\n"> <"\t\tCOMMIT\n"> <"\t\tcat-blob :1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tread blob_id type size <&3 &&\n"> <"\t\ttest_copy_bytes $size >actual <&3 &&\n"> <"\t\tread newline <&3 &&\n"> <"\n"> <"\t\techo\n"> <"\t) |\n"> <"\tgit fast-import --cat-blob-fd=3 3>blobs &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(PIPE)} {(SQ <"R: print staged blob within commit">)} { (SQ <"\n"> <"\trm -f blobs &&\n"> <"\techo \"A blob from _within_ the commit.\" >expect &&\n"> <"\tmkfifo blobs &&\n"> <"\t(\n"> <"\t\texec 3 <"\t\tcat <<-EOF &&\n"> <"\t\tfeature cat-blob\n"> <"\t\tcommit refs/heads/within\n"> <"\t\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\t\tdata < <"\t\tEmpty commit\n"> <"\t\tCOMMIT\n"> <"\t\tM 644 inline within\n"> <"\t\tdata < <"\t\tA blob from _within_ the commit.\n"> <"\t\tBLOB\n"> <"\t\tEOF\n"> <"\n"> <"\t\tto_get=$(\n"> <"\t\t\techo \"A blob from _within_ the commit.\" |\n"> <"\t\t\tgit hash-object --stdin\n"> <"\t\t) &&\n"> <"\t\techo \"cat-blob $to_get\" &&\n"> <"\n"> <"\t\tread blob_id type size <&3 &&\n"> <"\t\ttest_copy_bytes $size >actual <&3 &&\n"> <"\t\tread newline <&3 &&\n"> <"\n"> <"\t\techo deleteall\n"> <"\t) |\n"> <"\tgit fast-import --cat-blob-fd=3 3>blobs &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: quiet option results in no stats being output">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\toption git quiet\n"> <"\tblob\n"> <"\tdata 3\n"> <"\thi\n"> <"\n"> <"\tEOF\n"> <"\n"> <"\tcat input | git fast-import 2> output &&\n"> <"\ttest_must_be_empty output\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: feature done means terminating \"done\" is mandatory">)} { (SQ <"\n"> <"\techo feature done | test_must_fail git fast-import &&\n"> <"\ttest_must_fail git fast-import --done ) } ) (C {(test_expect_success)} {(SQ <"R: terminating \"done\" with trailing gibberish is ok">)} { (SQ <"\n"> <"\tgit fast-import <<-\\EOF &&\n"> <"\tfeature done\n"> <"\tdone\n"> <"\ttrailing gibberish\n"> <"\tEOF\n"> <"\tgit fast-import <<-\\EOF\n"> <"\tdone\n"> <"\tmore trailing gibberish\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: terminating \"done\" within commit">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tOBJID\n"> <"\t:000000 100644 OBJID OBJID A\thello.c\n"> <"\t:000000 100644 OBJID OBJID A\thello2.c\n"> <"\tEOF\n"> <"\tgit fast-import <<-EOF &&\n"> <"\tcommit refs/heads/done-ends\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tCommit terminated by \"done\" command\n"> <"\tEOT\n"> <"\tM 100644 inline hello.c\n"> <"\tdata < <"\tHello, world.\n"> <"\tEOT\n"> <"\tC hello.c hello2.c\n"> <"\tdone\n"> <"\tEOF\n"> <"\tgit rev-list done-ends |\n"> <"\tgit diff-tree -r --stdin --root --always |\n"> <"\tsed -e \"s/$_x40/OBJID/g\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: die on unknown option">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\toption git non-existing-option\n"> <"\tEOF\n"> <"\n"> <"\ttest_must_fail git fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: unknown commandline options are rejected">)} {(SQ <"\\\n"> <"\ttest_must_fail git fast-import --non-existing-option < /dev/null\n">)} ) (C {(test_expect_success)} {(SQ <"R: die on invalid option argument">)} { (SQ <"\n"> <"\techo \"option git active-branches=-5\" |\n"> <"\ttest_must_fail git fast-import &&\n"> <"\techo \"option git depth=\" |\n"> <"\ttest_must_fail git fast-import &&\n"> <"\ttest_must_fail git fast-import --depth=\"5 elephants\" ) } ) (C {(test_expect_success)} {(SQ <"R: ignore non-git options">)} { (SQ <"\n"> <"\tcat >input <<-EOF &&\n"> <"\toption non-existing-vcs non-existing-option\n"> <"\tEOF\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"R: corrupt lines do not mess marks file">)} { (SQ <"\n"> <"\trm -f io.marks &&\n"> <"\tblob=$(echo hi | git hash-object --stdin) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t:3 0000000000000000000000000000000000000000\n"> <"\t:1 $blob\n"> <"\t:2 $blob\n"> <"\tEOF\n"> <"\tcp expect io.marks &&\n"> <"\ttest_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\\EOF &&\n"> <"\n"> <"\tEOF\n"> <"\ttest_cmp expect io.marks\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: blob bigger than threshold">)} { (SQ <"\n"> <"\tblobsize=$((2*1024*1024 + 53)) &&\n"> <"\ttest-genrandom bar $blobsize >expect &&\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/big-file\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tR - big file\n"> <"\tCOMMIT\n"> <"\n"> <"\tM 644 inline big1\n"> <"\tdata $blobsize\n"> <"\tINPUT_END\n"> <"\tcat expect >>input &&\n"> <"\tcat >>input <<-INPUT_END &&\n"> <"\tM 644 inline big2\n"> <"\tdata $blobsize\n"> <"\tINPUT_END\n"> <"\tcat expect >>input &&\n"> <"\techo >>input &&\n"> <"\n"> <"\ttest_create_repo R &&\n"> <"\tgit --git-dir=R/.git config fastimport.unpackLimit 0 &&\n"> <"\tgit --git-dir=R/.git fast-import --big-file-threshold=1 ) } ) (C {(test_expect_success)} {(SQ <"R: verify created pack">)} {(SQ <"\n"> <"\t(\n"> <"\t\tcd R &&\n"> <"\t\tverify_packs -v > ../verify\n"> <"\t)\n">)} ) (C {(test_expect_success)} {(SQ <"R: verify written objects">)} { (SQ <"\n"> <"\tgit --git-dir=R/.git cat-file blob big-file:big1 >actual &&\n"> <"\ttest_cmp_bin expect actual &&\n"> <"\ta=$(git --git-dir=R/.git rev-parse big-file:big1) &&\n"> <"\tb=$(git --git-dir=R/.git rev-parse big-file:big2) &&\n"> <"\ttest $a = $b\n"> ) } ) (C {(test_expect_success)} {(SQ <"R: blob appears only once">)} {(SQ <"\n"> <"\tn=$(grep $a verify | wc -l) &&\n"> <"\ttest 1 = $n\n">)} ) (C {(test_expect_success)} {(SQ <"S: initialize for S tests">)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/S\n"> <"\tmark :301\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit 1\n"> <"\tCOMMIT\n"> <"\tM 100644 inline hello.c\n"> <"\tdata < <"\tblob 1\n"> <"\tBLOB\n"> <"\n"> <"\tcommit refs/heads/S\n"> <"\tmark :302\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit 2\n"> <"\tCOMMIT\n"> <"\tfrom :301\n"> <"\tM 100644 inline hello.c\n"> <"\tdata < <"\tblob 2\n"> <"\tBLOB\n"> <"\n"> <"\tblob\n"> <"\tmark :403\n"> <"\tdata < <"\tblob 3\n"> <"\tBLOB\n"> <"\n"> <"\tblob\n"> <"\tmark :202\n"> <"\tdata < <"\tnote 2\n"> <"\tBLOB\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import --export-marks=marks ) } ) (C {(test_expect_success)} {(SQ <"S: filemodify with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit N\n"> <"\tCOMMIT\n"> <"\tM 100644 :403x hello.c\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: filemodify with garbage after inline must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit N\n"> <"\tCOMMIT\n"> <"\tM 100644 inlineX hello.c\n"> <"\tdata < <"\tinline\n"> <"\tBLOB\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"nvalid dataref\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: filemodify with garbage after sha1 must fail">)} { (SQ <"\n"> <"\tsha1=$(grep :403 marks | cut -d\\ -f2) &&\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit N\n"> <"\tCOMMIT\n"> <"\tM 100644 ${sha1}x hello.c\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after SHA1\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: notemodify with garabge after mark dataref must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit S note dataref markref\n"> <"\tCOMMIT\n"> <"\tN :202x :302\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: notemodify with garbage after inline dataref must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit S note dataref inline\n"> <"\tCOMMIT\n"> <"\tN inlineX :302\n"> <"\tdata < <"\tnote blob\n"> <"\tBLOB\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"nvalid dataref\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: notemodify with garbage after sha1 dataref must fail">)} { (SQ <"\n"> <"\tsha1=$(grep :202 marks | cut -d\\ -f2) &&\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit S note dataref sha1\n"> <"\tCOMMIT\n"> <"\tN ${sha1}x :302\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after SHA1\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: notemodify with garbage after mark commit-ish must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/Snotes\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit S note commit-ish\n"> <"\tCOMMIT\n"> <"\tN :202 :302x\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: from with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail \\\n"> <"\tgit fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S2\n"> <"\tmark :303\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit 3\n"> <"\tCOMMIT\n"> <"\tfrom :301x\n"> <"\tM 100644 :403 hello.c\n"> <"\tEOF\n"> <"\n"> <"\n"> <"\t# go create the commit, need it for merge test\n"> <"\tgit fast-import --import-marks=marks --export-marks=marks <<-EOF &&\n"> <"\tcommit refs/heads/S2\n"> <"\tmark :303\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tcommit 3\n"> <"\tCOMMIT\n"> <"\tfrom :301\n"> <"\tM 100644 :403 hello.c\n"> <"\tEOF\n"> <"\n"> <"\t# now evaluate the error\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: merge with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcommit refs/heads/S\n"> <"\tmark :304\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tmerge 4\n"> <"\tCOMMIT\n"> <"\tfrom :302\n"> <"\tmerge :303x\n"> <"\tM 100644 :403 hello.c\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: tag with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\ttag refs/tags/Stag\n"> <"\tfrom :302x\n"> <"\ttagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\ttag S\n"> <"\tTAG\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: cat-blob with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tcat-blob :403x\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: ls with garbage after mark must fail">)} { (SQ <"\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tls :302x hello.c\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after mark\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"S: ls with garbage after sha1 must fail">)} { (SQ <"\n"> <"\tsha1=$(grep :302 marks | cut -d\\ -f2) &&\n"> <"\ttest_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&\n"> <"\tls ${sha1}x hello.c\n"> <"\tEOF\n"> <"\tcat err &&\n"> <"\ttest_i18ngrep \"space after tree-ish\" err\n"> ) } ) (C {(test_expect_success)} {(SQ <"T: ls root tree">)} { (SQ <"\n"> <"\tsed -e \"s/Z\\$//\" >expect <<-EOF &&\n"> <"\t040000 tree $(git rev-parse S^{tree})\tZ\n"> <"\tEOF\n"> <"\tsha1=$(git rev-parse --verify S) &&\n"> <"\tgit fast-import --import-marks=marks <<-EOF >actual &&\n"> <"\tls $sha1 \"\"\n"> <"\tEOF\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"T: delete branch">)} { (SQ <"\n"> <"\tgit branch to-delete &&\n"> <"\tgit fast-import <<-EOF &&\n"> <"\treset refs/heads/to-delete\n"> <"\tfrom 0000000000000000000000000000000000000000\n"> <"\tEOF\n"> <"\ttest_must_fail git rev-parse --verify refs/heads/to-delete\n"> ) } ) (C {(test_expect_success)} {(SQ <"T: empty reset doesnt delete branch">)} { (SQ <"\n"> <"\tgit branch not-to-delete &&\n"> <"\tgit fast-import <<-EOF &&\n"> <"\treset refs/heads/not-to-delete\n"> <"\tEOF\n"> <"\tgit show-ref &&\n"> <"\tgit rev-parse --verify refs/heads/not-to-delete\n"> ) } ) (C {(test_expect_success)} {(SQ <"U: initialize for U tests">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/U\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\ttest setup\n"> <"\tCOMMIT\n"> <"\tM 100644 inline hello.c\n"> <"\tdata < <"\tblob 1\n"> <"\tBLOB\n"> <"\tM 100644 inline good/night.txt\n"> <"\tdata < <"\tsleep well\n"> <"\tBLOB\n"> <"\tM 100644 inline good/bye.txt\n"> <"\tdata < <"\tau revoir\n"> <"\tBLOB\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"U: filedelete file succeeds">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/U\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tdelete good/night.txt\n"> <"\tCOMMIT\n"> <"\tfrom refs/heads/U^0\n"> <"\tD good/night.txt\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"U: validate file delete result">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D\tgood/night.txt\n" > <"\tEOF\n"> <"\n"> <"\tgit diff-tree -M -r U^1 U >actual &&\n"> <"\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"U: filedelete directory succeeds">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/U\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tdelete good dir\n"> <"\tCOMMIT\n"> <"\tfrom refs/heads/U^0\n"> <"\tD good\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"U: validate directory delete result">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D\tgood/bye.txt\n" > <"\tEOF\n"> <"\n"> <"\tgit diff-tree -M -r U^1 U >actual &&\n"> <"\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"U: filedelete root succeeds">)} { (SQ <"\n"> <"\tcat >input <<-INPUT_END &&\n"> <"\tcommit refs/heads/U\n"> <"\tcommitter $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n"> <"\tdata < <"\tmust succeed\n"> <"\tCOMMIT\n"> <"\tfrom refs/heads/U^0\n"> <"\tD \"\"\n"> <"\n"> <"\tINPUT_END\n"> <"\n"> <"\tgit fast-import ) } ) (C {(test_expect_success)} {(SQ <"U: validate root delete result">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> < "\t:100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D\thello.c\n" > <"\tEOF\n"> <"\n"> <"\tgit diff-tree -M -r U^1 U >actual &&\n"> <"\n"> <"\tcompare_diff_raw expect actual\n"> ) } ) (C {(test_done)}) ] )