Code

t3404: Add test case for auto-amending only edited commits after "edit"
[git.git] / t / t9300-fast-import.sh
index c4f4465dc687d30138a9111ae2efbc0e3aaf42b6..8b79de5b6345680bfc0a50f02a0334ddc67186c2 100755 (executable)
@@ -56,6 +56,12 @@ M 644 :2 file2
 M 644 :3 file3
 M 755 :4 file4
 
+tag series-A
+from :5
+data <<EOF
+An annotated tag without a tagger
+EOF
+
 INPUT_END
 test_expect_success \
     'A: create pack from stdin' \
@@ -74,7 +80,7 @@ EOF
 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
@@ -84,22 +90,34 @@ EOF
 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
+object $(git rev-parse refs/heads/master)
+type commit
+tag series-A
+
+An annotated tag without a tagger
+EOF
+test_expect_success 'A: verify tag/series-A' '
+       git cat-file tag tags/series-A >actual &&
+       test_cmp expect actual
+'
 
 cat >expect <<EOF
 :2 `git rev-parse --verify master:file2`
@@ -109,7 +127,7 @@ cat >expect <<EOF
 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' \
@@ -117,7 +135,7 @@ test_expect_success \
                --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
@@ -166,7 +184,7 @@ M 755 0000000000000000000000000000000000000001 zero1
 
 INPUT_END
 test_expect_success 'B: fail on invalid blob sha1' '
-    ! git-fast-import <input
+    test_must_fail git-fast-import <input
 '
 rm -f .git/objects/pack_* .git/objects/index_*
 
@@ -181,7 +199,7 @@ from refs/heads/master
 
 INPUT_END
 test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
-    ! git-fast-import <input
+    test_must_fail git-fast-import <input
 '
 rm -f .git/objects/pack_* .git/objects/index_*
 
@@ -196,7 +214,7 @@ from refs/heads/master
 
 INPUT_END
 test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
-    ! git-fast-import <input
+    test_must_fail git-fast-import <input
 '
 rm -f .git/objects/pack_* .git/objects/index_*
 
@@ -259,7 +277,7 @@ EOF
 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
@@ -316,13 +334,13 @@ echo "$file5_data" >expect
 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
@@ -340,7 +358,7 @@ from refs/heads/branch^0
 
 INPUT_END
 test_expect_success 'E: rfc2822 date, --date-format=raw' '
-    ! git-fast-import --date-format=raw <input
+    test_must_fail git-fast-import --date-format=raw <input
 '
 test_expect_success \
     'E: rfc2822 date, --date-format=rfc2822' \
@@ -358,7 +376,7 @@ EOF
 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
@@ -411,7 +429,7 @@ EOF
 test_expect_success \
        'F: verify other commit' \
        'git cat-file commit other >actual &&
-       git diff expect actual'
+       test_cmp expect actual'
 
 ###
 ### series G
@@ -489,7 +507,7 @@ echo "$file5_data" >expect
 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
@@ -515,7 +533,7 @@ EOF
 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
@@ -625,7 +643,7 @@ test_expect_success \
     '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
@@ -885,7 +903,7 @@ test_expect_success \
         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 &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 cat >input <<INPUT_END
 commit refs/heads/O4
@@ -916,6 +934,158 @@ test_expect_success \
        'O: progress outputs as requested by input' \
        'git-fast-import <input >actual &&
         grep "progress " <input >expect &&
-        git diff expect actual'
+        test_cmp expect actual'
+
+###
+### series P (gitlinks)
+###
+
+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 <<DATAEND
+[submodule "sub"]
+       path = sub
+       url = "`pwd`/sub"
+DATAEND
+
+commit refs/heads/subuse1
+mark :4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $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
+
+test_expect_success \
+       'P: supermodule & submodule mix' \
+       'git-fast-import <input &&
+        git checkout subuse1 &&
+        rm -rf sub && mkdir sub && cd sub &&
+        git init &&
+        git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
+        git checkout master &&
+        cd .. &&
+        git submodule init &&
+        git submodule update'
+
+SUBLAST=$(git-rev-parse --verify sub)
+SUBPREV=$(git-rev-parse --verify sub^)
+
+cat >input <<INPUT_END
+blob
+mark :1
+data <<DATAEND
+[submodule "sub"]
+       path = sub
+       url = "`pwd`/sub"
+DATAEND
+
+commit refs/heads/subuse2
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $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
+
+test_expect_success \
+       'P: verbatim SHA gitlinks' \
+       'git branch -D sub &&
+        git gc && git prune &&
+        git-fast-import <input &&
+        test $(git-rev-parse --verify subuse2) = $(git-rev-parse --verify subuse1)'
+
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/subuse3
+mark :1
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/subuse2
+M 160000 inline sub
+data <<DATA
+$SUBPREV
+DATA
+
+INPUT_END
+
+test_expect_success 'P: fail on inline gitlink' '
+    test_must_fail git-fast-import <input'
+
+test_tick
+cat >input <<INPUT_END
+blob
+mark :1
+data <<DATA
+$SUBPREV
+DATA
+
+commit refs/heads/subuse3
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/subuse2
+M 160000 :1 sub
+
+INPUT_END
+
+test_expect_success 'P: fail on blob mark in gitlink' '
+    test_must_fail git-fast-import <input'
 
 test_done