diff options
Diffstat (limited to 't/t9350-fast-export.sh')
-rwxr-xr-x | t/t9350-fast-export.sh | 215 |
1 files changed, 91 insertions, 124 deletions
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh index 46700dbc40..8f85c69d62 100755 --- a/t/t9350-fast-export.sh +++ b/t/t9350-fast-export.sh @@ -48,12 +48,11 @@ test_expect_success 'fast-export | fast-import' ' mkdir new && git --git-dir=new/.git init && git fast-export --all >actual && - (cd new && - git fast-import && - test $MAIN = $(git rev-parse --verify refs/heads/main) && - test $REIN = $(git rev-parse --verify refs/tags/rein) && - test $WER = $(git rev-parse --verify refs/heads/wer) && - test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual + git -C new fast-import <actual && + test $MAIN = $(git -C new rev-parse --verify refs/heads/main) && + test $REIN = $(git -C new rev-parse --verify refs/tags/rein) && + test $WER = $(git -C new rev-parse --verify refs/heads/wer) && + test $MUSS = $(git -C new rev-parse --verify refs/tags/muss) ' @@ -87,13 +86,11 @@ test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' ' test_expect_success 'fast-export main~2..main' ' git fast-export main~2..main >actual && - sed "s/main/partial/" actual | - (cd new && - git fast-import && - test $MAIN != $(git rev-parse --verify refs/heads/partial) && - git diff --exit-code main partial && - git diff --exit-code main^ partial^ && - test_must_fail git rev-parse partial~2) + sed "s/main/partial/" actual | git -C new fast-import && + test $MAIN != $(git -C new rev-parse --verify refs/heads/partial) && + git -C new diff --exit-code main partial && + git -C new diff --exit-code main^ partial^ && + test_must_fail git -C new rev-parse partial~2 ' @@ -102,10 +99,8 @@ test_expect_success 'fast-export --reference-excluded-parents main~2..main' ' git fast-export --reference-excluded-parents main~2..main >actual && grep commit.refs/heads/main actual >commit-count && test_line_count = 2 commit-count && - sed "s/main/rewrite/" actual | - (cd new && - git fast-import && - test $MAIN = $(git rev-parse --verify refs/heads/rewrite)) + sed "s/main/rewrite/" actual | git -C new fast-import && + test $MAIN = $(git -C new rev-parse --verify refs/heads/rewrite) ' test_expect_success 'fast-export --show-original-ids' ' @@ -133,20 +128,19 @@ test_expect_success ICONV 'reencoding iso-8859-7' ' echo rosten >file && git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && - sed "s/wer/i18n/" iso-8859-7.fi | - (cd new && - git fast-import && - # The commit object, if not re-encoded, would be 200 bytes plus hash. - # Removing the "encoding iso-8859-7\n" header drops 20 bytes. - # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7 - # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for - # the expected size. - test $(($(test_oid hexsz) + 181)) -eq "$(git cat-file -s i18n)" && - # ...and for the expected translation of bytes. - git cat-file commit i18n >actual && - grep $(printf "\317\200") actual && - # Also make sure the commit does not have the "encoding" header - ! grep ^encoding actual) + sed "s/wer/i18n/" iso-8859-7.fi | git -C new fast-import && + + # The commit object, if not re-encoded, would be 200 bytes plus hash. + # Removing the "encoding iso-8859-7\n" header drops 20 bytes. + # Re-encoding the Pi character from \xF0 (\360) in iso-8859-7 + # to \xCF\x80 (\317\200) in UTF-8 adds a byte. Check for + # the expected size. + test $(($(test_oid hexsz) + 181)) -eq "$(git -C new cat-file -s i18n)" && + # ...and for the expected translation of bytes. + git -C new cat-file commit i18n >actual && + grep $(printf "\317\200") actual && + # Also make sure the commit does not have the "encoding" header + ! grep ^encoding actual ' test_expect_success 'aborting on iso-8859-7' ' @@ -165,20 +159,19 @@ test_expect_success 'preserving iso-8859-7' ' echo rosten >file && git commit -s -F "$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt" file && git fast-export --reencode=no wer^..wer >iso-8859-7.fi && - sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | - (cd new && - git fast-import && - # The commit object, if not re-encoded, is 200 bytes plus hash. - # Removing the "encoding iso-8859-7\n" header would drops 20 - # bytes. Re-encoding the Pi character from \xF0 (\360) in - # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte. - # Check for the expected size... - test $(($(test_oid hexsz) + 200)) -eq "$(git cat-file -s i18n-no-recoding)" && - # ...as well as the expected byte. - git cat-file commit i18n-no-recoding >actual && - grep $(printf "\360") actual && - # Also make sure the commit has the "encoding" header - grep ^encoding actual) + sed "s/wer/i18n-no-recoding/" iso-8859-7.fi | git -C new fast-import && + + # The commit object, if not re-encoded, is 200 bytes plus hash. + # Removing the "encoding iso-8859-7\n" header would drops 20 + # bytes. Re-encoding the Pi character from \xF0 (\360) in + # iso-8859-7 to \xCF\x80 (\317\200) in UTF-8 adds a byte. + # Check for the expected size... + test $(($(test_oid hexsz) + 200)) -eq "$(git -C new cat-file -s i18n-no-recoding)" && + # ...as well as the expected byte. + git -C new cat-file commit i18n-no-recoding >actual && + grep $(printf "\360") actual && + # Also make sure the commit has the "encoding" header + grep ^encoding actual ' test_expect_success 'encoding preserved if reencoding fails' ' @@ -188,18 +181,17 @@ test_expect_success 'encoding preserved if reencoding fails' ' echo rosten >file && git commit -s -F "$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt" file && git fast-export --reencode=yes wer^..wer >iso-8859-7.fi && - sed "s/wer/i18n-invalid/" iso-8859-7.fi | - (cd new && - git fast-import && - git cat-file commit i18n-invalid >actual && - # Make sure the commit still has the encoding header - grep ^encoding actual && - # Verify that the commit has the expected size; i.e. - # that no bytes were re-encoded to a different encoding. - test $(($(test_oid hexsz) + 212)) -eq "$(git cat-file -s i18n-invalid)" && - # ...and check for the original special bytes - grep $(printf "\360") actual && - grep $(printf "\377") actual) + sed "s/wer/i18n-invalid/" iso-8859-7.fi | git -C new fast-import && + git -C new cat-file commit i18n-invalid >actual && + + # Make sure the commit still has the encoding header + grep ^encoding actual && + # Verify that the commit has the expected size; i.e. + # that no bytes were re-encoded to a different encoding. + test $(($(test_oid hexsz) + 212)) -eq "$(git -C new cat-file -s i18n-invalid)" && + # ...and check for the original special bytes + grep $(printf "\360") actual && + grep $(printf "\377") actual ' test_expect_success 'import/export-marks' ' @@ -316,12 +308,9 @@ test_expect_success GPG 'signed-commits=verbatim' ' git fast-export --signed-commits=verbatim --reencode=no commit-signing >output && test_grep -E "^gpgsig $GIT_DEFAULT_HASH openpgp" output && grep "encoding ISO-8859-1" output && - ( - cd new && - git fast-import && - STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) && - test $COMMIT_SIGNING = $STRIPPED - ) <output + git -C new fast-import <output && + STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) && + test $COMMIT_SIGNING = $STRIPPED ' @@ -331,12 +320,9 @@ test_expect_success GPG 'signed-commits=warn-verbatim' ' test_grep -E "^gpgsig $GIT_DEFAULT_HASH openpgp" output && grep "encoding ISO-8859-1" output && test -s err && - ( - cd new && - git fast-import && - STRIPPED=$(git rev-parse --verify refs/heads/commit-signing) && - test $COMMIT_SIGNING = $STRIPPED - ) <output + git -C new fast-import <output && + STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) && + test $COMMIT_SIGNING = $STRIPPED ' @@ -345,12 +331,9 @@ test_expect_success GPG 'signed-commits=strip' ' git fast-export --signed-commits=strip --reencode=no commit-signing >output && ! grep ^gpgsig output && grep "^encoding ISO-8859-1" output && - sed "s/commit-signing/commit-strip-signing/" output | ( - cd new && - git fast-import && - STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) && - test $COMMIT_SIGNING != $STRIPPED - ) + sed "s/commit-signing/commit-strip-signing/" output | git -C new fast-import && + STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) && + test $COMMIT_SIGNING != $STRIPPED ' @@ -360,12 +343,9 @@ test_expect_success GPG 'signed-commits=warn-strip' ' ! grep ^gpgsig output && grep "^encoding ISO-8859-1" output && test -s err && - sed "s/commit-signing/commit-strip-signing/" output | ( - cd new && - git fast-import && - STRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) && - test $COMMIT_SIGNING != $STRIPPED - ) + sed "s/commit-signing/commit-strip-signing/" output | git -C new fast-import && + STRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) && + test $COMMIT_SIGNING != $STRIPPED ' @@ -386,14 +366,11 @@ test_expect_success GPGSM 'round-trip X.509 signed commit' ' git fast-export --signed-commits=verbatim x509-signing >output && test_grep -E "^gpgsig $GIT_DEFAULT_HASH x509" output && - ( - cd new && - git fast-import && - git cat-file commit refs/heads/x509-signing >actual && - grep "^gpgsig" actual && - IMPORTED=$(git rev-parse refs/heads/x509-signing) && - test $X509_COMMIT = $IMPORTED - ) <output + git -C new fast-import <output && + git -C new cat-file commit refs/heads/x509-signing >actual && + grep "^gpgsig" actual && + IMPORTED=$(git -C new rev-parse refs/heads/x509-signing) && + test $X509_COMMIT = $IMPORTED ' @@ -414,14 +391,11 @@ test_expect_success GPGSSH 'round-trip SSH signed commit' ' git fast-export --signed-commits=verbatim ssh-signing >output && test_grep -E "^gpgsig $GIT_DEFAULT_HASH ssh" output && - ( - cd new && - git fast-import && - git cat-file commit refs/heads/ssh-signing >actual && - grep "^gpgsig" actual && - IMPORTED=$(git rev-parse refs/heads/ssh-signing) && - test $SSH_COMMIT = $IMPORTED - ) <output + git -C new fast-import <output && + git -C new cat-file commit refs/heads/ssh-signing >actual && + grep "^gpgsig" actual && + IMPORTED=$(git -C new rev-parse refs/heads/ssh-signing) && + test $SSH_COMMIT = $IMPORTED ' @@ -461,14 +435,13 @@ test_expect_success 'submodule fast-export | fast-import' ' mkdir new && git --git-dir=new/.git init && git fast-export --signed-tags=strip --all >actual && - (cd new && - git fast-import && - test "$SUBENT1" = "$(git ls-tree refs/heads/main^ sub)" && - test "$SUBENT2" = "$(git ls-tree refs/heads/main sub)" && - git checkout main && - git submodule init && - git submodule update && - cmp sub/file ../sub/file) <actual + git -C new fast-import <actual && + test "$SUBENT1" = "$(git -C new ls-tree refs/heads/main^ sub)" && + test "$SUBENT2" = "$(git -C new ls-tree refs/heads/main sub)" && + git -C new checkout main && + git -C new submodule init && + git -C new submodule update && + cmp new/sub/file sub/file ' @@ -510,10 +483,8 @@ test_expect_success 'fast-export -C -C | fast-import' ' git --git-dir=new/.git init && git fast-export -C -C --signed-tags=strip --all > output && grep "^C file2 file4\$" output && - cat output | - (cd new && - git fast-import && - test $ENTRY = $(git rev-parse --verify refs/heads/copy)) + git -C new fast-import <output && + test $ENTRY = $(git -C new rev-parse --verify refs/heads/copy) ' @@ -986,21 +957,17 @@ test_expect_success GPG 'export and import of doubly signed commit' ' git -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output && test_grep -E "^gpgsig sha1 openpgp" output && test_grep -E "^gpgsig sha256 openpgp" output && - - ( - cd new && - git fast-import && - git cat-file commit refs/heads/dual-signed >actual && - test_grep -E "^gpgsig " actual && - test_grep -E "^gpgsig-sha256 " actual && - IMPORTED=$(git rev-parse refs/heads/dual-signed) && - if test "$GIT_DEFAULT_HASH" = "sha1" - then - test $SHA1_B = $IMPORTED - else - test $SHA256_B = $IMPORTED - fi - ) <output + git -C new fast-import <output && + git -C new cat-file commit refs/heads/dual-signed >actual && + test_grep -E "^gpgsig " actual && + test_grep -E "^gpgsig-sha256 " actual && + IMPORTED=$(git -C new rev-parse refs/heads/dual-signed) && + if test "$GIT_DEFAULT_HASH" = "sha1" + then + test $SHA1_B = $IMPORTED + else + test $SHA256_B = $IMPORTED + fi ' test_done |