Imported Upstream version 2.16.0
[platform/upstream/git.git] / t / t9350-fast-export.sh
index b00196b..866ddf6 100755 (executable)
@@ -70,7 +70,7 @@ test_expect_success 'iso-8859-1' '
 
        git config i18n.commitencoding ISO8859-1 &&
        # use author and committer name in ISO-8859-1 to match it.
-       . "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+       . "$TEST_DIRECTORY"/t3901/8859-1.txt &&
        test_tick &&
        echo rosten >file &&
        git commit -s -m den file &&
@@ -146,6 +146,12 @@ test_expect_success 'signed-tags=strip' '
 
 '
 
+test_expect_success 'signed-tags=warn-strip' '
+       git fast-export --signed-tags=warn-strip sign-your-name >output 2>err &&
+       ! grep PGP output &&
+       test -s err
+'
+
 test_expect_success 'setup submodule' '
 
        git checkout -f master &&
@@ -157,7 +163,7 @@ test_expect_success 'setup submodule' '
                git add file &&
                git commit -m sub_initial
        ) &&
-       git submodule add "`pwd`/sub" sub &&
+       git submodule add "$(pwd)/sub" sub &&
        git commit -m initial &&
        test_tick &&
        (
@@ -228,7 +234,7 @@ test_expect_success 'fast-export -C -C | fast-import' '
        mkdir new &&
        git --git-dir=new/.git init &&
        git fast-export -C -C --signed-tags=strip --all > output &&
-       grep "^C file6 file7\$" output &&
+       grep "^C file2 file4\$" output &&
        cat output |
        (cd new &&
         git fast-import &&
@@ -303,7 +309,7 @@ test_expect_success 'dropping tag of filtered out object' '
 (
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
-       test_cmp output expected
+       test_cmp expected output
 )
 '
 
@@ -320,7 +326,7 @@ test_expect_success 'rewriting tag of filtered out object' '
 (
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
-       test_cmp output expected
+       test_cmp expected output
 )
 '
 
@@ -351,7 +357,7 @@ test_expect_failure 'no exact-ref revisions included' '
        (
                cd limit-by-paths &&
                git fast-export master~2..master~1 > output &&
-               test_cmp output expected
+               test_cmp expected output
        )
 '
 
@@ -371,7 +377,7 @@ test_expect_success 'full-tree re-shows unmodified files'        '
 
 test_expect_success 'set-up a few more tags for tag export tests' '
        git checkout -f master &&
-       HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
+       HEAD_TREE=$(git show -s --pretty=raw HEAD | grep tree | sed "s/tree //") &&
        git tag    tree_tag        -m "tagging a tree" $HEAD_TREE &&
        git tag -a tree_tag-obj    -m "tagging a tree" $HEAD_TREE &&
        git tag    tag-obj_tag     -m "tagging a tag" tree_tag-obj &&
@@ -390,7 +396,7 @@ test_expect_success 'tree_tag-obj'    'git fast-export tree_tag-obj'
 test_expect_success 'tag-obj_tag'     'git fast-export tag-obj_tag'
 test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
 
-test_expect_success SYMLINKS 'directory becomes symlink'        '
+test_expect_success 'directory becomes symlink'        '
        git init dirtosymlink &&
        git init result &&
        (
@@ -402,8 +408,7 @@ test_expect_success SYMLINKS 'directory becomes symlink'        '
                git add foo/world bar/world &&
                git commit -q -mone &&
                git rm -r foo &&
-               ln -s bar foo &&
-               git add foo &&
+               test_ln_s_add bar foo &&
                git commit -q -mtwo
        ) &&
        (
@@ -417,7 +422,7 @@ test_expect_success SYMLINKS 'directory becomes symlink'        '
 test_expect_success 'fast-export quotes pathnames' '
        git init crazy-paths &&
        (cd crazy-paths &&
-        blob=`echo foo | git hash-object -w --stdin` &&
+        blob=$(echo foo | git hash-object -w --stdin) &&
         git update-index --add \
                --cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \
                --cacheinfo 100644 $blob "path with \"quote\"" \
@@ -430,7 +435,7 @@ test_expect_success 'fast-export quotes pathnames' '
         git commit -m rename &&
         git read-tree --empty &&
         git commit -m deletion &&
-        git fast-export HEAD >export.out &&
+        git fast-export -M HEAD >export.out &&
         git rev-list HEAD >expect &&
         git init result &&
         cd result &&
@@ -440,4 +445,99 @@ test_expect_success 'fast-export quotes pathnames' '
        )
 '
 
+test_expect_success 'test bidirectionality' '
+       >marks-cur &&
+       >marks-new &&
+       git init marks-test &&
+       git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \
+       git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new &&
+       (cd marks-test &&
+       git reset --hard &&
+       echo Wohlauf > file &&
+       git commit -a -m "back in time") &&
+       git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \
+       git fast-import --export-marks=marks-cur --import-marks=marks-cur
+'
+
+cat > expected << EOF
+blob
+mark :13
+data 5
+bump
+
+commit refs/heads/master
+mark :14
+author A U Thor <author@example.com> 1112912773 -0700
+committer C O Mitter <committer@example.com> 1112912773 -0700
+data 5
+bump
+from :12
+M 100644 :13 file
+
+EOF
+
+test_expect_success 'avoid uninteresting refs' '
+       > tmp-marks &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > /dev/null &&
+       git tag v1.0 &&
+       git branch uninteresting &&
+       echo bump > file &&
+       git commit -a -m bump &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks ^uninteresting ^v1.0 master > actual &&
+       test_cmp expected actual
+'
+
+cat > expected << EOF
+reset refs/heads/master
+from :14
+
+EOF
+
+test_expect_success 'refs are updated even if no commits need to be exported' '
+       > tmp-marks &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > /dev/null &&
+       git fast-export --import-marks=tmp-marks \
+               --export-marks=tmp-marks master > actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'use refspec' '
+       git fast-export --refspec refs/heads/master:refs/heads/foobar master | \
+               grep "^commit " | sort | uniq > actual &&
+       echo "commit refs/heads/foobar" > expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'delete refspec' '
+       git branch to-delete &&
+       git fast-export --refspec :refs/heads/to-delete to-delete ^to-delete > actual &&
+       cat > expected <<-EOF &&
+       reset refs/heads/to-delete
+       from 0000000000000000000000000000000000000000
+
+       EOF
+       test_cmp expected actual
+'
+
+test_expect_success 'when using -C, do not declare copy when source of copy is also modified' '
+       test_create_repo src &&
+       echo a_line >src/file.txt &&
+       git -C src add file.txt &&
+       git -C src commit -m 1st_commit &&
+
+       cp src/file.txt src/file2.txt &&
+       echo another_line >>src/file.txt &&
+       git -C src add file.txt file2.txt &&
+       git -C src commit -m 2nd_commit &&
+
+       test_create_repo dst &&
+       git -C src fast-export --all -C | git -C dst fast-import &&
+       git -C src show >expected &&
+       git -C dst show >actual &&
+       test_cmp expected actual
+'
+
 test_done