{"thread":{"id":"63848","subject":"[PATCH] t9350: redirect input to only fast-import","startedAt":"2025-07-25T16:06:02Z","lastAt":"2025-07-26T13:45:22Z","messageCount":2,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"522753","messageId":"20250725160536.2909011-1-christian.couder@gmail.com","threadId":"63848","inReplyTo":null,"subject":"[PATCH] t9350: redirect input to only fast-import","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2025-07-25T16:05:36Z","receivedAt":"2025-07-25T16:06:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"A number of tests in \"t9350-fast-export.sh\" are using sub-shells to\nredirect content to a number of commands instead of only\n`git fast-import`.\n\nThis is confusing and possibly error-prone, so let's change those tests\nso that no sub-shell is used and the content goes only to\n`git fast-import`.\n\nReported-by: Elijah Newren <newren@gmail.com>\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n\nThis addresses some leftover work discussed in:\n\nhttps://lore.kernel.org/git/CABPp-BHM5afgiUf7GsTPWmrf_tm6mWnvHWMKiZPxApJzN-U8gg@mail.gmail.com/\n\n\nt/t9350-fast-export.sh | 215 +++++++++++++++++------------------------\n 1 file changed, 91 insertions(+), 124 deletions(-)\n\ndiff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\nindex 46700dbc40..8f85c69d62 100755\n--- a/t/t9350-fast-export.sh\n+++ b/t/t9350-fast-export.sh\n@@ -48,12 +48,11 @@ test_expect_success 'fast-export | fast-import' '\n \tmkdir new &&\n \tgit --git-dir=new/.git init &&\n \tgit fast-export --all >actual &&\n-\t(cd new &&\n-\t git fast-import &&\n-\t test $MAIN = $(git rev-parse --verify refs/heads/main) &&\n-\t test $REIN = $(git rev-parse --verify refs/tags/rein) &&\n-\t test $WER = $(git rev-parse --verify refs/heads/wer) &&\n-\t test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual\n+\tgit -C new fast-import <actual &&\n+\ttest $MAIN = $(git -C new rev-parse --verify refs/heads/main) &&\n+\ttest $REIN = $(git -C new rev-parse --verify refs/tags/rein) &&\n+\ttest $WER = $(git -C new rev-parse --verify refs/heads/wer) &&\n+\ttest $MUSS = $(git -C new rev-parse --verify refs/tags/muss)\n \n '\n \n@@ -87,13 +86,11 @@ test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' '\n test_expect_success 'fast-export main~2..main' '\n \n \tgit fast-export main~2..main >actual &&\n-\tsed \"s/main/partial/\" actual |\n-\t\t(cd new &&\n-\t\t git fast-import &&\n-\t\t test $MAIN != $(git rev-parse --verify refs/heads/partial) &&\n-\t\t git diff --exit-code main partial &&\n-\t\t git diff --exit-code main^ partial^ &&\n-\t\t test_must_fail git rev-parse partial~2)\n+\tsed \"s/main/partial/\" actual | git -C new fast-import &&\n+\ttest $MAIN != $(git -C new rev-parse --verify refs/heads/partial) &&\n+\tgit -C new diff --exit-code main partial &&\n+\tgit -C new diff --exit-code main^ partial^ &&\n+\ttest_must_fail git -C new rev-parse partial~2\n \n '\n \n@@ -102,10 +99,8 @@ test_expect_success 'fast-export --reference-excluded-parents main~2..main' '\n \tgit fast-export --reference-excluded-parents main~2..main >actual &&\n \tgrep commit.refs/heads/main actual >commit-count &&\n \ttest_line_count = 2 commit-count &&\n-\tsed \"s/main/rewrite/\" actual |\n-\t\t(cd new &&\n-\t\t git fast-import &&\n-\t\t test $MAIN = $(git rev-parse --verify refs/heads/rewrite))\n+\tsed \"s/main/rewrite/\" actual | git -C new fast-import &&\n+\ttest $MAIN = $(git -C new rev-parse --verify refs/heads/rewrite)\n '\n \n test_expect_success 'fast-export --show-original-ids' '\n@@ -133,20 +128,19 @@ test_expect_success ICONV 'reencoding iso-8859-7' '\n \techo rosten >file &&\n \tgit commit -s -F \"$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt\" file &&\n \tgit fast-export --reencode=yes wer^..wer >iso-8859-7.fi &&\n-\tsed \"s/wer/i18n/\" iso-8859-7.fi |\n-\t\t(cd new &&\n-\t\t git fast-import &&\n-\t\t # The commit object, if not re-encoded, would be 200 bytes plus hash.\n-\t\t # Removing the \"encoding iso-8859-7\\n\" header drops 20 bytes.\n-\t\t # Re-encoding the Pi character from \\xF0 (\\360) in iso-8859-7\n-\t\t # to \\xCF\\x80 (\\317\\200) in UTF-8 adds a byte.  Check for\n-\t\t # the expected size.\n-\t\t test $(($(test_oid hexsz) + 181)) -eq \"$(git cat-file -s i18n)\" &&\n-\t\t # ...and for the expected translation of bytes.\n-\t\t git cat-file commit i18n >actual &&\n-\t\t grep $(printf \"\\317\\200\") actual &&\n-\t\t # Also make sure the commit does not have the \"encoding\" header\n-\t\t ! grep ^encoding actual)\n+\tsed \"s/wer/i18n/\" iso-8859-7.fi | git -C new fast-import &&\n+\n+\t# The commit object, if not re-encoded, would be 200 bytes plus hash.\n+\t# Removing the \"encoding iso-8859-7\\n\" header drops 20 bytes.\n+\t# Re-encoding the Pi character from \\xF0 (\\360) in iso-8859-7\n+\t# to \\xCF\\x80 (\\317\\200) in UTF-8 adds a byte.  Check for\n+\t# the expected size.\n+\ttest $(($(test_oid hexsz) + 181)) -eq \"$(git -C new cat-file -s i18n)\" &&\n+\t# ...and for the expected translation of bytes.\n+\tgit -C new cat-file commit i18n >actual &&\n+\tgrep $(printf \"\\317\\200\") actual &&\n+\t# Also make sure the commit does not have the \"encoding\" header\n+\t! grep ^encoding actual\n '\n \n test_expect_success 'aborting on iso-8859-7' '\n@@ -165,20 +159,19 @@ test_expect_success 'preserving iso-8859-7' '\n \techo rosten >file &&\n \tgit commit -s -F \"$TEST_DIRECTORY/t9350/simple-iso-8859-7-commit-message.txt\" file &&\n \tgit fast-export --reencode=no wer^..wer >iso-8859-7.fi &&\n-\tsed \"s/wer/i18n-no-recoding/\" iso-8859-7.fi |\n-\t\t(cd new &&\n-\t\t git fast-import &&\n-\t\t # The commit object, if not re-encoded, is 200 bytes plus hash.\n-\t\t # Removing the \"encoding iso-8859-7\\n\" header would drops 20\n-\t\t # bytes.  Re-encoding the Pi character from \\xF0 (\\360) in\n-\t\t # iso-8859-7 to \\xCF\\x80 (\\317\\200) in UTF-8 adds a byte.\n-\t\t # Check for the expected size...\n-\t\t test $(($(test_oid hexsz) + 200)) -eq \"$(git cat-file -s i18n-no-recoding)\" &&\n-\t\t # ...as well as the expected byte.\n-\t\t git cat-file commit i18n-no-recoding >actual &&\n-\t\t grep $(printf \"\\360\") actual &&\n-\t\t # Also make sure the commit has the \"encoding\" header\n-\t\t grep ^encoding actual)\n+\tsed \"s/wer/i18n-no-recoding/\" iso-8859-7.fi | git -C new fast-import &&\n+\n+\t# The commit object, if not re-encoded, is 200 bytes plus hash.\n+\t# Removing the \"encoding iso-8859-7\\n\" header would drops 20\n+\t# bytes.  Re-encoding the Pi character from \\xF0 (\\360) in\n+\t# iso-8859-7 to \\xCF\\x80 (\\317\\200) in UTF-8 adds a byte.\n+\t# Check for the expected size...\n+\ttest $(($(test_oid hexsz) + 200)) -eq \"$(git -C new cat-file -s i18n-no-recoding)\" &&\n+\t# ...as well as the expected byte.\n+\tgit -C new cat-file commit i18n-no-recoding >actual &&\n+\tgrep $(printf \"\\360\") actual &&\n+\t# Also make sure the commit has the \"encoding\" header\n+\tgrep ^encoding actual\n '\n \n test_expect_success 'encoding preserved if reencoding fails' '\n@@ -188,18 +181,17 @@ test_expect_success 'encoding preserved if reencoding fails' '\n \techo rosten >file &&\n \tgit commit -s -F \"$TEST_DIRECTORY/t9350/broken-iso-8859-7-commit-message.txt\" file &&\n \tgit fast-export --reencode=yes wer^..wer >iso-8859-7.fi &&\n-\tsed \"s/wer/i18n-invalid/\" iso-8859-7.fi |\n-\t\t(cd new &&\n-\t\t git fast-import &&\n-\t\t git cat-file commit i18n-invalid >actual &&\n-\t\t # Make sure the commit still has the encoding header\n-\t\t grep ^encoding actual &&\n-\t\t # Verify that the commit has the expected size; i.e.\n-\t\t # that no bytes were re-encoded to a different encoding.\n-\t\t test $(($(test_oid hexsz) + 212)) -eq \"$(git cat-file -s i18n-invalid)\" &&\n-\t\t # ...and check for the original special bytes\n-\t\t grep $(printf \"\\360\") actual &&\n-\t\t grep $(printf \"\\377\") actual)\n+\tsed \"s/wer/i18n-invalid/\" iso-8859-7.fi | git -C new fast-import &&\n+\tgit -C new cat-file commit i18n-invalid >actual &&\n+\n+\t# Make sure the commit still has the encoding header\n+\tgrep ^encoding actual &&\n+\t# Verify that the commit has the expected size; i.e.\n+\t# that no bytes were re-encoded to a different encoding.\n+\ttest $(($(test_oid hexsz) + 212)) -eq \"$(git -C new cat-file -s i18n-invalid)\" &&\n+\t# ...and check for the original special bytes\n+\tgrep $(printf \"\\360\") actual &&\n+\tgrep $(printf \"\\377\") actual\n '\n \n test_expect_success 'import/export-marks' '\n@@ -316,12 +308,9 @@ test_expect_success GPG 'signed-commits=verbatim' '\n \tgit fast-export --signed-commits=verbatim --reencode=no commit-signing >output &&\n \ttest_grep -E \"^gpgsig $GIT_DEFAULT_HASH openpgp\" output &&\n \tgrep \"encoding ISO-8859-1\" output &&\n-\t(\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tSTRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&\n-\t\ttest $COMMIT_SIGNING = $STRIPPED\n-\t) <output\n+\tgit -C new fast-import <output &&\n+\tSTRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) &&\n+\ttest $COMMIT_SIGNING = $STRIPPED\n \n '\n \n@@ -331,12 +320,9 @@ test_expect_success GPG 'signed-commits=warn-verbatim' '\n \ttest_grep -E \"^gpgsig $GIT_DEFAULT_HASH openpgp\" output &&\n \tgrep \"encoding ISO-8859-1\" output &&\n \ttest -s err &&\n-\t(\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tSTRIPPED=$(git rev-parse --verify refs/heads/commit-signing) &&\n-\t\ttest $COMMIT_SIGNING = $STRIPPED\n-\t) <output\n+\tgit -C new fast-import <output &&\n+\tSTRIPPED=$(git -C new rev-parse --verify refs/heads/commit-signing) &&\n+\ttest $COMMIT_SIGNING = $STRIPPED\n \n '\n \n@@ -345,12 +331,9 @@ test_expect_success GPG 'signed-commits=strip' '\n \tgit fast-export --signed-commits=strip --reencode=no commit-signing >output &&\n \t! grep ^gpgsig output &&\n \tgrep \"^encoding ISO-8859-1\" output &&\n-\tsed \"s/commit-signing/commit-strip-signing/\" output | (\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tSTRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&\n-\t\ttest $COMMIT_SIGNING != $STRIPPED\n-\t)\n+\tsed \"s/commit-signing/commit-strip-signing/\" output | git -C new fast-import &&\n+\tSTRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) &&\n+\ttest $COMMIT_SIGNING != $STRIPPED\n \n '\n \n@@ -360,12 +343,9 @@ test_expect_success GPG 'signed-commits=warn-strip' '\n \t! grep ^gpgsig output &&\n \tgrep \"^encoding ISO-8859-1\" output &&\n \ttest -s err &&\n-\tsed \"s/commit-signing/commit-strip-signing/\" output | (\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tSTRIPPED=$(git rev-parse --verify refs/heads/commit-strip-signing) &&\n-\t\ttest $COMMIT_SIGNING != $STRIPPED\n-\t)\n+\tsed \"s/commit-signing/commit-strip-signing/\" output | git -C new fast-import &&\n+\tSTRIPPED=$(git -C new rev-parse --verify refs/heads/commit-strip-signing) &&\n+\ttest $COMMIT_SIGNING != $STRIPPED\n \n '\n \n@@ -386,14 +366,11 @@ test_expect_success GPGSM 'round-trip X.509 signed commit' '\n \n \tgit fast-export --signed-commits=verbatim x509-signing >output &&\n \ttest_grep -E \"^gpgsig $GIT_DEFAULT_HASH x509\" output &&\n-\t(\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tgit cat-file commit refs/heads/x509-signing >actual &&\n-\t\tgrep \"^gpgsig\" actual &&\n-\t\tIMPORTED=$(git rev-parse refs/heads/x509-signing) &&\n-\t\ttest $X509_COMMIT = $IMPORTED\n-\t) <output\n+\tgit -C new fast-import <output &&\n+\tgit -C new cat-file commit refs/heads/x509-signing >actual &&\n+\tgrep \"^gpgsig\" actual &&\n+\tIMPORTED=$(git -C new rev-parse refs/heads/x509-signing) &&\n+\ttest $X509_COMMIT = $IMPORTED\n \n '\n \n@@ -414,14 +391,11 @@ test_expect_success GPGSSH 'round-trip SSH signed commit' '\n \n \tgit fast-export --signed-commits=verbatim ssh-signing >output &&\n \ttest_grep -E \"^gpgsig $GIT_DEFAULT_HASH ssh\" output &&\n-\t(\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tgit cat-file commit refs/heads/ssh-signing >actual &&\n-\t\tgrep \"^gpgsig\" actual &&\n-\t\tIMPORTED=$(git rev-parse refs/heads/ssh-signing) &&\n-\t\ttest $SSH_COMMIT = $IMPORTED\n-\t) <output\n+\tgit -C new fast-import <output &&\n+\tgit -C new cat-file commit refs/heads/ssh-signing >actual &&\n+\tgrep \"^gpgsig\" actual &&\n+\tIMPORTED=$(git -C new rev-parse refs/heads/ssh-signing) &&\n+\ttest $SSH_COMMIT = $IMPORTED\n \n '\n \n@@ -461,14 +435,13 @@ test_expect_success 'submodule fast-export | fast-import' '\n \tmkdir new &&\n \tgit --git-dir=new/.git init &&\n \tgit fast-export --signed-tags=strip --all >actual &&\n-\t(cd new &&\n-\t git fast-import &&\n-\t test \"$SUBENT1\" = \"$(git ls-tree refs/heads/main^ sub)\" &&\n-\t test \"$SUBENT2\" = \"$(git ls-tree refs/heads/main sub)\" &&\n-\t git checkout main &&\n-\t git submodule init &&\n-\t git submodule update &&\n-\t cmp sub/file ../sub/file) <actual\n+\tgit -C new fast-import <actual &&\n+\ttest \"$SUBENT1\" = \"$(git -C new ls-tree refs/heads/main^ sub)\" &&\n+\ttest \"$SUBENT2\" = \"$(git -C new ls-tree refs/heads/main sub)\" &&\n+\tgit -C new checkout main &&\n+\tgit -C new submodule init &&\n+\tgit -C new submodule update &&\n+\tcmp new/sub/file sub/file\n \n '\n \n@@ -510,10 +483,8 @@ test_expect_success 'fast-export -C -C | fast-import' '\n \tgit --git-dir=new/.git init &&\n \tgit fast-export -C -C --signed-tags=strip --all > output &&\n \tgrep \"^C file2 file4\\$\" output &&\n-\tcat output |\n-\t(cd new &&\n-\t git fast-import &&\n-\t test $ENTRY = $(git rev-parse --verify refs/heads/copy))\n+\tgit -C new fast-import <output &&\n+\ttest $ENTRY = $(git -C new rev-parse --verify refs/heads/copy)\n \n '\n \n@@ -986,21 +957,17 @@ test_expect_success GPG 'export and import of doubly signed commit' '\n \tgit -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output &&\n \ttest_grep -E \"^gpgsig sha1 openpgp\" output &&\n \ttest_grep -E \"^gpgsig sha256 openpgp\" output &&\n-\n-\t(\n-\t\tcd new &&\n-\t\tgit fast-import &&\n-\t\tgit cat-file commit refs/heads/dual-signed >actual &&\n-\t\ttest_grep -E \"^gpgsig \" actual &&\n-\t\ttest_grep -E \"^gpgsig-sha256 \" actual &&\n-\t\tIMPORTED=$(git rev-parse refs/heads/dual-signed) &&\n-\t\tif test \"$GIT_DEFAULT_HASH\" = \"sha1\"\n-\t\tthen\n-\t\t\ttest $SHA1_B = $IMPORTED\n-\t\telse\n-\t\t\ttest $SHA256_B = $IMPORTED\n-\t\tfi\n-\t) <output\n+\tgit -C new fast-import <output &&\n+\tgit -C new cat-file commit refs/heads/dual-signed >actual &&\n+\ttest_grep -E \"^gpgsig \" actual &&\n+\ttest_grep -E \"^gpgsig-sha256 \" actual &&\n+\tIMPORTED=$(git -C new rev-parse refs/heads/dual-signed) &&\n+\tif test \"$GIT_DEFAULT_HASH\" = \"sha1\"\n+\tthen\n+\t\ttest $SHA1_B = $IMPORTED\n+\telse\n+\t\ttest $SHA256_B = $IMPORTED\n+\tfi\n '\n \n test_done\n-- \n2.50.1.439.g97e14d99f6\n\n"},{"id":"522790","messageId":"xmqqpldn12xd.fsf@gitster.g","threadId":"63848","inReplyTo":"20250725160536.2909011-1-christian.couder@gmail.com","subject":"Re: [PATCH] t9350: redirect input to only fast-import","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-07-26T13:45:18Z","receivedAt":"2025-07-26T13:45:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n> A number of tests in \"t9350-fast-export.sh\" are using sub-shells to\n> redirect content to a number of commands instead of only\n> `git fast-import`.\n>\n> This is confusing and possibly error-prone, so let's change those tests\n> so that no sub-shell is used and the content goes only to\n> `git fast-import`.\n>\n> Reported-by: Elijah Newren <newren@gmail.com>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>\n> This addresses some leftover work discussed in:\n>\n> https://lore.kernel.org/git/CABPp-BHM5afgiUf7GsTPWmrf_tm6mWnvHWMKiZPxApJzN-U8gg@mail.gmail.com/\n>\n>\n> t/t9350-fast-export.sh | 215 +++++++++++++++++------------------------\n>  1 file changed, 91 insertions(+), 124 deletions(-)\n>\n> diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh\n> index 46700dbc40..8f85c69d62 100755\n> --- a/t/t9350-fast-export.sh\n> +++ b/t/t9350-fast-export.sh\n> @@ -48,12 +48,11 @@ test_expect_success 'fast-export | fast-import' '\n>  \tmkdir new &&\n>  \tgit --git-dir=new/.git init &&\n>  \tgit fast-export --all >actual &&\n> -\t(cd new &&\n> -\t git fast-import &&\n> -\t test $MAIN = $(git rev-parse --verify refs/heads/main) &&\n> -\t test $REIN = $(git rev-parse --verify refs/tags/rein) &&\n> -\t test $WER = $(git rev-parse --verify refs/heads/wer) &&\n> -\t test $MUSS = $(git rev-parse --verify refs/tags/muss)) <actual\n> +\tgit -C new fast-import <actual &&\n> +\ttest $MAIN = $(git -C new rev-parse --verify refs/heads/main) &&\n> +\ttest $REIN = $(git -C new rev-parse --verify refs/tags/rein) &&\n> +\ttest $WER = $(git -C new rev-parse --verify refs/heads/wer) &&\n> +\ttest $MUSS = $(git -C new rev-parse --verify refs/tags/muss)\n\nThat's a great simplification, especially with the use of \"git -C\n<there>\" construct to move there just for that single command.  Very\nnice.\n"}]}