test_expect_success \
'A: verify commit' \
'git cat-file commit master | sed 1d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
cat >expect <<EOF
100644 blob file2
test_expect_success \
'A: verify tree' \
'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- git diff expect actual'
+ test_cmp expect actual'
echo "$file2_data" >expect
test_expect_success \
'A: verify file2' \
- 'git cat-file blob master:file2 >actual && git diff expect actual'
+ 'git cat-file blob master:file2 >actual && test_cmp expect actual'
echo "$file3_data" >expect
test_expect_success \
'A: verify file3' \
- 'git cat-file blob master:file3 >actual && git diff expect actual'
+ 'git cat-file blob master:file3 >actual && test_cmp expect actual'
printf "$file4_data" >expect
test_expect_success \
'A: verify file4' \
- 'git cat-file blob master:file4 >actual && git diff expect actual'
+ 'git cat-file blob master:file4 >actual && test_cmp expect actual'
cat >expect <<EOF
:2 `git rev-parse --verify master:file2`
EOF
test_expect_success \
'A: verify marks output' \
- 'git diff expect marks.out'
+ 'test_cmp expect marks.out'
test_expect_success \
'A: verify marks import' \
--import-marks=marks.out \
--export-marks=marks.new \
</dev/null &&
- git diff -u expect marks.new'
+ test_cmp expect marks.new'
test_tick
cat >input <<INPUT_END
M 755 0000000000000000000000000000000000000001 zero1
INPUT_END
-test_expect_failure \
- 'B: fail on invalid blob sha1' \
- 'git-fast-import <input'
+test_expect_success 'B: fail on invalid blob sha1' '
+ ! git-fast-import <input
+'
+rm -f .git/objects/pack_* .git/objects/index_*
+
+cat >input <<INPUT_END
+commit .badbranchname
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/master
+
+INPUT_END
+test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
+ ! git-fast-import <input
+'
+rm -f .git/objects/pack_* .git/objects/index_*
+
+cat >input <<INPUT_END
+commit bad[branch]name
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/master
+
+INPUT_END
+test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
+ ! git-fast-import <input
+'
rm -f .git/objects/pack_* .git/objects/index_*
+cat >input <<INPUT_END
+commit TEMP_TAG
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+tag base
+COMMIT
+
+from refs/heads/master
+
+INPUT_END
+test_expect_success \
+ 'B: accept branch name "TEMP_TAG"' \
+ 'git-fast-import <input &&
+ test -f .git/TEMP_TAG &&
+ test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
+rm -f .git/TEMP_TAG
+
###
### series C
###
test_expect_success \
'C: verify commit' \
'git cat-file commit branch | sed 1d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
cat >expect <<EOF
:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
test_expect_success \
'D: verify file5' \
'git cat-file blob branch:newdir/interesting >actual &&
- git diff expect actual'
+ test_cmp expect actual'
echo "$file6_data" >expect
test_expect_success \
'D: verify file6' \
'git cat-file blob branch:newdir/exec.sh >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series E
from refs/heads/branch^0
INPUT_END
-test_expect_failure \
- 'E: rfc2822 date, --date-format=raw' \
- 'git-fast-import --date-format=raw <input'
+test_expect_success 'E: rfc2822 date, --date-format=raw' '
+ ! git-fast-import --date-format=raw <input
+'
test_expect_success \
'E: rfc2822 date, --date-format=rfc2822' \
'git-fast-import --date-format=rfc2822 <input'
test_expect_success \
'E: verify commit' \
'git cat-file commit branch | sed 1,2d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series F
test_expect_success \
'F: verify other commit' \
'git cat-file commit other >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series G
test_expect_success \
'H: verify file' \
'git cat-file blob H:h/e/l/lo >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series I
test_expect_success \
'I: verify edge list' \
'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series J
'L: verify internal tree sorting' \
'git-fast-import <input &&
git diff-tree --abbrev --raw L^ L >output &&
- git diff expect output'
+ test_cmp expect output'
###
### series M
'git-fast-import <input &&
test `git-rev-parse N2^{tree}` = `git-rev-parse N3^{tree}`'
+###
+### series O
+###
+
+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 <<COMMIT
+dirty directory copy
+COMMIT
+
+# don't forget the import blank line!
+#
+# yes, we started from our usual base of branch^0.
+# i like branch^0.
+from refs/heads/branch^0
+# and we need to reuse file2/file5 from N3 above.
+M 644 inline file2/file5
+# otherwise the tree will be different
+data <<EOF
+$file5_data
+EOF
+
+# don't forget to copy file2 to file3
+C file2 file3
+#
+# or to delete file5 from file2.
+D file2/file5
+# are we done yet?
+
+INPUT_END
+
+test_expect_success \
+ 'O: comments are all skipped' \
+ 'git-fast-import <input &&
+ test `git-rev-parse N3` = `git-rev-parse O1`'
+
+cat >input <<INPUT_END
+commit refs/heads/O2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+dirty directory copy
+COMMIT
+from refs/heads/branch^0
+M 644 inline file2/file5
+data <<EOF
+$file5_data
+EOF
+C file2 file3
+D file2/file5
+
+INPUT_END
+
+test_expect_success \
+ 'O: blank lines not necessary after data commands' \
+ 'git-fast-import <input &&
+ test `git-rev-parse N3` = `git-rev-parse O2`'
+
+test_expect_success \
+ 'O: repack before next test' \
+ 'git repack -a -d'
+
+cat >input <<INPUT_END
+commit refs/heads/O3
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zstring
+COMMIT
+commit refs/heads/O3
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zof
+COMMIT
+checkpoint
+commit refs/heads/O3
+mark :5
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zempty
+COMMIT
+checkpoint
+commit refs/heads/O3
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zcommits
+COMMIT
+reset refs/tags/O3-2nd
+from :5
+reset refs/tags/O3-3rd
+from :5
+INPUT_END
+
+cat >expect <<INPUT_END
+string
+of
+empty
+commits
+INPUT_END
+test_expect_success \
+ 'O: blank lines not necessary after other commands' \
+ 'git-fast-import <input &&
+ test 8 = `find .git/objects/pack -type f | wc -l` &&
+ test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
+ git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
+ test_cmp expect actual'
+
+cat >input <<INPUT_END
+commit refs/heads/O4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zstring
+COMMIT
+commit refs/heads/O4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zof
+COMMIT
+progress Two commits down, 2 to go!
+commit refs/heads/O4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zempty
+COMMIT
+progress Three commits down, 1 to go!
+commit refs/heads/O4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+zcommits
+COMMIT
+progress I'm done!
+INPUT_END
+test_expect_success \
+ 'O: progress outputs as requested by input' \
+ 'git-fast-import <input >actual &&
+ grep "progress " <input >expect &&
+ test_cmp expect actual'
+
test_done