{"thread":{"id":"57467","subject":"[PATCH 0/2] Subject: [PATCH 0/2] [GSoC][PATCH 0/2] t0000-t0050: avoid pipes with Git on LHS","startedAt":"2022-02-24T05:47:35Z","lastAt":"2022-03-12T10:27:55Z","messageCount":19,"participants":["Shubham Mishra","Ævar Arnfjörð Bjarmason","Taylor Blau","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"449389","messageId":"20220224054720.23996-1-shivam828787@gmail.com","threadId":"57467","inReplyTo":null,"subject":"[PATCH 0/2] Subject: [PATCH 0/2] [GSoC][PATCH 0/2] t0000-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-24T05:47:18Z","receivedAt":"2022-02-24T05:47:35Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"As a microproject, I remove all pipes with GIT on LHS from\nfiles t0000 to t0050.\n\nShubham Mishra (2):\n  t0001-t0028: avoid pipes with Git on LHS\n  t0030-t0050: avoid pipes with Git on LHS\n\n t/t0000-basic.sh            | 10 +++--\n t/t0022-crlf-rename.sh      |  4 +-\n t/t0025-crlf-renormalize.sh |  4 +-\n t/t0027-auto-crlf.sh        | 12 +++---\n t/t0030-stripspace.sh       | 81 ++++++++++++++++++++++++-------------\n t/t0050-filesystem.sh       |  3 +-\n 6 files changed, 72 insertions(+), 42 deletions(-)\n\n\nbase-commit: e6ebfd0e8cbbd10878070c8a356b5ad1b3ca464e\n-- \n2.25.1\n\n"},{"id":"449390","messageId":"20220224054720.23996-2-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220224054720.23996-1-shivam828787@gmail.com","subject":"[PATCH 1/2] t0001-t0028: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-24T05:47:19Z","receivedAt":"2022-02-24T05:47:37Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0000-basic.sh            | 10 ++++++----\n t/t0022-crlf-rename.sh      |  4 ++--\n t/t0025-crlf-renormalize.sh |  4 ++--\n t/t0027-auto-crlf.sh        | 12 ++++++------\n 4 files changed, 16 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex b007f0efef..b5fa76059b 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '\n \tmv path2 path0 &&\n \tmv tmp path2 &&\n \tgit update-index --add --replace path2 path0/file2 &&\n-\tnumpath0=$(git ls-files path0 | wc -l) &&\n+\tgit ls-files path0 >tmp &&\n+\tnumpath0=$(wc -l <tmp) &&\n \ttest $numpath0 = 1\n '\n \n@@ -1104,12 +1105,13 @@ test_expect_success 'very long name in the index handled sanely' '\n \t>path4 &&\n \tgit update-index --add path4 &&\n \t(\n-\t\tgit ls-files -s path4 |\n-\t\tsed -e \"s/\t.*/\t/\" |\n+\t\tgit ls-files -s path4 >tmp &&\n+\t\tsed -e \"s/\t.*/\t/\" tmp |\n \t\ttr -d \"\\012\" &&\n \t\techo \"$a\"\n \t) | git update-index --index-info &&\n-\tlen=$(git ls-files \"a*\" | wc -c) &&\n+\tgit ls-files \"a*\" >tmp &&\n+\tlen=$(wc -c <tmp) &&\n \ttest $len = 4098\n '\n \ndiff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh\nindex c1a331e9e9..9fe9891251 100755\n--- a/t/t0022-crlf-rename.sh\n+++ b/t/t0022-crlf-rename.sh\n@@ -24,8 +24,8 @@ test_expect_success setup '\n \n test_expect_success 'diff -M' '\n \n-\tgit diff-tree -M -r --name-status HEAD^ HEAD |\n-\tsed -e \"s/R[0-9]*/RNUM/\" >actual &&\n+\tgit diff-tree -M -r --name-status HEAD^ HEAD >tmp &&\n+\tsed -e \"s/R[0-9]*/RNUM/\" tmp >actual &&\n \techo \"RNUM\tsample\telpmas\" >expect &&\n \ttest_cmp expect actual\n \ndiff --git a/t/t0025-crlf-renormalize.sh b/t/t0025-crlf-renormalize.sh\nindex 81447978b7..f7202c192e 100755\n--- a/t/t0025-crlf-renormalize.sh\n+++ b/t/t0025-crlf-renormalize.sh\n@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '\n \ti/lf w/lf attr/text=auto LF.txt\n \ti/lf w/mixed attr/text=auto CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol |\n-\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol >tmp &&\n+\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex c5f7ac63b0..0feb41a23f 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -311,8 +311,8 @@ checkout_files () {\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n \t\tEOF\n-\t\tgit ls-files --eol crlf_false_attr__* |\n-\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\t\tgit ls-files --eol crlf_false_attr__* >tmp &&\n+\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '\n \ti/ w/crlf TeBi_126_CL\n \ti/ w/-text TeBi_126_CLC\n \tEOF\n-\tgit ls-files --eol -o |\n+\tgit ls-files --eol -o >tmp &&\n \tsed -n -e \"/TeBi_/{s!attr/[\t]*!!g\n \ts!\t! !g\n \ts!  *! !g\n \tp\n-\t}\" | sort >actual &&\n+\t}\" tmp | sort >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -617,8 +617,8 @@ test_expect_success 'ls-files --eol -d -z' '\n \ti/lf w/ crlf_false_attr__LF.txt\n \ti/mixed w/ crlf_false_attr__CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol -d |\n-\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol -d >tmp &&\n+\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.25.1\n\n"},{"id":"449391","messageId":"20220224054720.23996-3-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220224054720.23996-1-shivam828787@gmail.com","subject":"[PATCH 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-24T05:47:20Z","receivedAt":"2022-02-24T05:47:44Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0030-stripspace.sh | 81 ++++++++++++++++++++++++++++---------------\n t/t0050-filesystem.sh |  3 +-\n 2 files changed, 56 insertions(+), 28 deletions(-)\n\ndiff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\nindex ae1ca380c1..4d0af9bf98 100755\n--- a/t/t0030-stripspace.sh\n+++ b/t/t0030-stripspace.sh\n@@ -225,32 +225,48 @@ test_expect_success \\\n \n test_expect_success \\\n     'text without newline at end should end with newline' '\n-    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n+    printf \"$ttt\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt$ttt\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt$ttt$ttt\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0\n '\n \n # text plus spaces at the end:\n \n test_expect_success \\\n     'text plus spaces without newline at end should end with newline' '\n-    test $(printf \"$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss$sss\" | git stripspace | wc -l) -gt 0\n+    printf \"$ttt$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0 &&\n+    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n+    test $(wc -l <tmp) -gt 0\n '\n \n test_expect_success \\\n     'text plus spaces without newline at end should not show spaces' '\n-    ! (printf \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    printf \"$ttt$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    printf \"$ttt$ttt$sss\" | git stripspace &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n+    ! (grep \"  \" tmp >/dev/nul) &&\n+    printf \"$ttt$sss$sss\" | git stripspace &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n+    ! (grep \"  \" tmp >/dev/null)\n '\n \n test_expect_success \\\n@@ -282,12 +298,18 @@ test_expect_success \\\n \n test_expect_success \\\n     'text plus spaces at end should not show spaces' '\n-    ! (echo \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    echo \"$ttt$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp>/dev/null) &&\n+    echo \"$ttt$ttt$ttt$sss\" &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp >/dev/null) &&\n+    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \"  \" tmp >/dev/null)\n '\n \n test_expect_success \\\n@@ -339,11 +361,16 @@ test_expect_success \\\n \n test_expect_success \\\n     'spaces without newline at end should not show spaces' '\n-    ! (printf \"\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null)\n+    printf \"\" | git stripspace >tmp &&\n+    ! ( grep \" \" tmp >/dev/null) &&\n+    printf \"$sss\" | git stripspace >tmp &&\n+    ! ( grep \" \" tmp >/dev/null) &&\n+    printf \"$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \" \" tmp >/dev/null) &&\n+    printf \"$sss$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \" \" tmp >/dev/null) &&\n+    printf \"$sss$sss$sss$sss\" | git stripspace >tmp &&\n+    ! (grep \" \" tmp >/dev/null)\n '\n \n test_expect_success \\\ndiff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\nindex afc343cf9b..5c9dc90d0b 100755\n--- a/t/t0050-filesystem.sh\n+++ b/t/t0050-filesystem.sh\n@@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '\n \trm camelcase &&\n \techo 1 >CamelCase &&\n \tgit add CamelCase &&\n-\tcamel=$(git ls-files | grep -i camelcase) &&\n+\tgit ls-files >tmp &&\n+\tcamel=$(grep -i camelcase tmp) &&\n \ttest $(echo \"$camel\" | wc -l) = 1 &&\n \ttest \"z$(git cat-file blob :$camel)\" = z1\n '\n-- \n2.25.1\n\n"},{"id":"449392","messageId":"CAC316V4F0UTEk8+=oThMNeQpsUjs78EkY2Qrw6rz7TCKXSyqzA@mail.gmail.com","threadId":"57467","inReplyTo":"20220224054720.23996-1-shivam828787@gmail.com","subject":"Re: [PATCH 0/2] Subject: [PATCH 0/2] [GSoC][PATCH 0/2] t0000-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-24T05:51:05Z","receivedAt":"2022-02-24T05:51:22Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"for further reference, you can follow the discussion on my last\npatchset - https://lore.kernel.org/git/20220222114313.14921-1-shivam828787@gmail.com/\n\nOn Thu, Feb 24, 2022 at 11:17 AM Shubham Mishra <shivam828787@gmail.com> wrote:\n>\n> As a microproject, I remove all pipes with GIT on LHS from\n> files t0000 to t0050.\n>\n> Shubham Mishra (2):\n>   t0001-t0028: avoid pipes with Git on LHS\n>   t0030-t0050: avoid pipes with Git on LHS\n>\n>  t/t0000-basic.sh            | 10 +++--\n>  t/t0022-crlf-rename.sh      |  4 +-\n>  t/t0025-crlf-renormalize.sh |  4 +-\n>  t/t0027-auto-crlf.sh        | 12 +++---\n>  t/t0030-stripspace.sh       | 81 ++++++++++++++++++++++++-------------\n>  t/t0050-filesystem.sh       |  3 +-\n>  6 files changed, 72 insertions(+), 42 deletions(-)\n>\n>\n> base-commit: e6ebfd0e8cbbd10878070c8a356b5ad1b3ca464e\n> --\n> 2.25.1\n>\n"},{"id":"449398","messageId":"220224.86o82wab31.gmgdl@evledraar.gmail.com","threadId":"57467","inReplyTo":"20220224054720.23996-3-shivam828787@gmail.com","subject":"Re: [PATCH 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-02-24T08:59:45Z","receivedAt":"2022-02-24T09:05:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Feb 24 2022, Shubham Mishra wrote:\n\n> Pipes ignore error codes of LHS command and thus we should not use\n> them with Git in tests. As an alternative, use a 'tmp' file to write\n> the Git output so we can test the exit code.\n>\n> Signed-off-by: Shubham Mishra <shivam828787@gmail.com>\n> ---\n>  t/t0030-stripspace.sh | 81 ++++++++++++++++++++++++++++---------------\n>  t/t0050-filesystem.sh |  3 +-\n>  2 files changed, 56 insertions(+), 28 deletions(-)\n>\n> diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\n> index ae1ca380c1..4d0af9bf98 100755\n> --- a/t/t0030-stripspace.sh\n> +++ b/t/t0030-stripspace.sh\n> @@ -225,32 +225,48 @@ test_expect_success \\\n>  \n>  test_expect_success \\\n>      'text without newline at end should end with newline' '\n> -    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n> +    printf \"$ttt\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt$ttt\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt$ttt$ttt\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0\n>  '\n\nYou're modifying some tests here that are using some old coding style,\nso maybe it's better to adjust it while we're at it?\n\nAlso I think this would be a lot nicer with test_stdout_line_count and a\nhelper to deal with that pritnf, e.g.:\n\t\n\tdiff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\n\tindex ae1ca380c1a..d48a3579511 100755\n\t--- a/t/t0030-stripspace.sh\n\t+++ b/t/t0030-stripspace.sh\n\t@@ -223,12 +223,15 @@ test_expect_success \\\n\t     test_cmp expect actual\n\t '\n\t \n\t-test_expect_success \\\n\t-    'text without newline at end should end with newline' '\n\t-    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n\t-    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n\t-    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n\t-    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n\t+printf_git_stripspace () {\n\t+\tprintf \"$1\" | git stripspace\n\t+}\n\t+\n\t+test_expect_success 'text without newline at end should end with newline' '\n\t+\ttest_stdout_line_count -gt 0 printf_git_stripspace \"$ttt\" &&\n\t+\ttest_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt\" &&\n\t+\ttest_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt\" &&\n\t+\ttest_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$ttt\"\n\t '\n\t \n\t # text plus spaces at the end:\n\n>  # text plus spaces at the end:\n>  \n>  test_expect_success \\\n>      'text plus spaces without newline at end should end with newline' '\n> -    test $(printf \"$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n> -    test $(printf \"$ttt$sss$sss$sss\" | git stripspace | wc -l) -gt 0\n> +    printf \"$ttt$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0 &&\n> +    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n> +    test $(wc -l <tmp) -gt 0\n>  '\n\nditto.\n\n>  test_expect_success \\\n>      'text plus spaces without newline at end should not show spaces' '\n> -    ! (printf \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n> +    printf \"$ttt$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    printf \"$ttt$ttt$sss\" | git stripspace &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n> +    ! (grep \"  \" tmp >/dev/nul) &&\n> +    printf \"$ttt$sss$sss\" | git stripspace &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n> +    ! (grep \"  \" tmp >/dev/null)\n>  '\n\nThis is not on you, but generally we don't pipe \"grep\" to >/dev/null,\nand just let the --verbose option do its work.\n\nWith/without that change you no longer need the () subshell here.\n\n>  test_expect_success \\\n> @@ -282,12 +298,18 @@ test_expect_success \\\n>  \n>  test_expect_success \\\n>      'text plus spaces at end should not show spaces' '\n> -    ! (echo \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n> +    echo \"$ttt$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp>/dev/null) &&\n> +    echo \"$ttt$ttt$ttt$sss\" &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp >/dev/null) &&\n> +    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \"  \" tmp >/dev/null)\n>  '\n>  \n>  test_expect_success \\\n> @@ -339,11 +361,16 @@ test_expect_success \\\n>  \n>  test_expect_success \\\n>      'spaces without newline at end should not show spaces' '\n> -    ! (printf \"\" | git stripspace | grep \" \" >/dev/null) &&\n> -    ! (printf \"$sss\" | git stripspace | grep \" \" >/dev/null) &&\n> -    ! (printf \"$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n> -    ! (printf \"$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n> -    ! (printf \"$sss$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null)\n> +    printf \"\" | git stripspace >tmp &&\n> +    ! ( grep \" \" tmp >/dev/null) &&\n> +    printf \"$sss\" | git stripspace >tmp &&\n> +    ! ( grep \" \" tmp >/dev/null) &&\n> +    printf \"$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \" \" tmp >/dev/null) &&\n> +    printf \"$sss$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \" \" tmp >/dev/null) &&\n> +    printf \"$sss$sss$sss$sss\" | git stripspace >tmp &&\n> +    ! (grep \" \" tmp >/dev/null)\n>  '\n\nditto for these.\n\n>  test_expect_success \\\n> diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\n> index afc343cf9b..5c9dc90d0b 100755\n> --- a/t/t0050-filesystem.sh\n> +++ b/t/t0050-filesystem.sh\n> @@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '\n>  \trm camelcase &&\n>  \techo 1 >CamelCase &&\n>  \tgit add CamelCase &&\n> -\tcamel=$(git ls-files | grep -i camelcase) &&\n> +\tgit ls-files >tmp &&\n> +\tcamel=$(grep -i camelcase tmp) &&\n>  \ttest $(echo \"$camel\" | wc -l) = 1 &&\n>  \ttest \"z$(git cat-file blob :$camel)\" = z1\n>  '\n\n"},{"id":"449670","messageId":"CAC316V4a37rsVpemARu17h2e0bj=ahsWOxjBEwO=BiWou+4aBw@mail.gmail.com","threadId":"57467","inReplyTo":"220224.86o82wab31.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-26T12:09:22Z","receivedAt":"2022-02-26T12:09:43Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Hi,\n\nThanks for Reviewing.\n\n> You're modifying some tests here that are using some old coding style,\n> so maybe it's better to adjust it while we're at it?\n>\n> Also I think this would be a lot nicer with test_stdout_line_count and a\n> helper to deal with that pritnf, e.g.:\n>\n>         diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\n>         index ae1ca380c1a..d48a3579511 100755\n>         --- a/t/t0030-stripspace.sh\n>         +++ b/t/t0030-stripspace.sh\n>         @@ -223,12 +223,15 @@ test_expect_success \\\n>              test_cmp expect actual\n>          '\n>\n>         -test_expect_success \\\n>         -    'text without newline at end should end with newline' '\n>         -    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n>         -    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n>         -    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n>         -    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n>         +printf_git_stripspace () {\n>         +       printf \"$1\" | git stripspace\n>         +}\n>         +\n>         +test_expect_success 'text without newline at end should end with newline' '\n>         +       test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt\" &&\n>         +       test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt\" &&\n>         +       test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt\" &&\n>         +       test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$ttt\"\n>          '\n>\n>          # text plus spaces at the end:\n>\n\nit makes sense to improve this code as we are touching it, this way\nlooks much better. I will implement it.\n\n\n> This is not on you, but generally we don't pipe \"grep\" to >/dev/null,\n> and just let the --verbose option do its work.\nI don't think I understood this, I guess you are talking about the\n\"-v\" flag that stands for invert match? I didn't find \"--verbose\" with\ngrep.\nPlease correct me if I am wrong.\n\n> With/without that change you no longer need the () subshell here.\nsure.\n\nThanks,\nShubham\n"},{"id":"449673","messageId":"Yhpjy77nWZc4oTll@nand.local","threadId":"57467","inReplyTo":"CAC316V4F0UTEk8+=oThMNeQpsUjs78EkY2Qrw6rz7TCKXSyqzA@mail.gmail.com","subject":"Re: [PATCH 0/2] Subject: [PATCH 0/2] [GSoC][PATCH 0/2] t0000-t0050: avoid pipes with Git on LHS","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-02-26T17:30:51Z","receivedAt":"2022-02-26T17:30:57Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Feb 24, 2022 at 11:21:05AM +0530, Shubham Mishra wrote:\n> for further reference, you can follow the discussion on my last\n> patchset - https://lore.kernel.org/git/20220222114313.14921-1-shivam828787@gmail.com/\n\nIn the future, you can use `--in-reply-to` to make sure that subsequent\nversions are attached to the previous version's thread.\n\nThanks,\nTaylor\n"},{"id":"449674","messageId":"YhpkO8ThwaHK3LIF@nand.local","threadId":"57467","inReplyTo":"220224.86o82wab31.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-02-26T17:32:43Z","receivedAt":"2022-02-26T17:32:49Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Feb 24, 2022 at 09:59:45AM +0100, Ævar Arnfjörð Bjarmason wrote:\n> You're modifying some tests here that are using some old coding style,\n> so maybe it's better to adjust it while we're at it?\n>\n> Also I think this would be a lot nicer with test_stdout_line_count and a\n> helper to deal with that pritnf, e.g.:\n\nThanks, Ævar for the quality review. I have nothing to add here.\n\nThanks,\nTaylor\n"},{"id":"449693","messageId":"20220227122453.25278-1-shivam828787@gmail.com","threadId":"57467","inReplyTo":"220224.86o82wab31.gmgdl@evledraar.gmail.com","subject":"[GSoC] [PATCH v2 0/2] avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-27T12:24:51Z","receivedAt":"2022-02-27T12:25:11Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"changes since v1:\n* replaced \"wc -l\" with test_stdout_line_count \n* removed unnecessary \"()\" subshells\n\nShubham Mishra (2):\n  t0001-t0028: avoid pipes with Git on LHS\n  t0030-t0050: avoid pipes with Git on LHS\n\n t/t0000-basic.sh            | 10 +++--\n t/t0022-crlf-rename.sh      |  4 +-\n t/t0025-crlf-renormalize.sh |  4 +-\n t/t0027-auto-crlf.sh        | 12 +++---\n t/t0030-stripspace.sh       | 75 ++++++++++++++++++++++++-------------\n t/t0050-filesystem.sh       |  3 +-\n 6 files changed, 66 insertions(+), 42 deletions(-)\n\nRange-diff against v1:\n1:  2a219ace42 = 1:  2a219ace42 t0001-t0028: avoid pipes with Git on LHS\n2:  d08c144476 ! 2:  c90fc271d9 t0030-t0050: avoid pipes with Git on LHS\n    @@ Commit message\n         Signed-off-by: Shubham Mishra <shivam828787@gmail.com>\n     \n      ## t/t0030-stripspace.sh ##\n    +@@ t/t0030-stripspace.sh: s40='                                        '\n    + sss=\"$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40\" # 400\n    + ttt=\"$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40\" # 400\n    + \n    ++printf_git_stripspace () {\n    ++    printf \"$1\" | git stripspace\n    ++}\n    ++\n    + test_expect_success \\\n    +     'long lines without spaces should be unchanged' '\n    +     echo \"$ttt\" >expect &&\n     @@ t/t0030-stripspace.sh: test_expect_success \\\n      \n      test_expect_success \\\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n     -    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n     -    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n    -+    printf \"$ttt\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt$ttt\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt$ttt$ttt\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$ttt\"\n      '\n      \n      # text plus spaces at the end:\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    test $(printf \"$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n     -    test $(printf \"$ttt$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n     -    test $(printf \"$ttt$sss$sss$sss\" | git stripspace | wc -l) -gt 0\n    -+    printf \"$ttt$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0 &&\n    -+    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n    -+    test $(wc -l <tmp) -gt 0\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$sss\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss$sss\" &&\n    ++    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss$sss\"\n      '\n      \n      test_expect_success \\\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n     -    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n     +    printf \"$ttt$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    printf \"$ttt$ttt$sss\" | git stripspace &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n    -+    ! (grep \"  \" tmp >/dev/nul) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    printf \"$ttt$sss$sss\" | git stripspace &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n    -+    ! (grep \"  \" tmp >/dev/null)\n    ++    ! grep \"  \" tmp >/dev/null\n      '\n      \n      test_expect_success \\\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n     -    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n     +    echo \"$ttt$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp>/dev/null) &&\n    ++    ! grep \"  \" tmp>/dev/null &&\n     +    echo \"$ttt$ttt$ttt$sss\" &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp >/dev/null) &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \"  \" tmp >/dev/null)\n    ++    ! grep \"  \" tmp >/dev/null\n      '\n      \n      test_expect_success \\\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    ! (printf \"$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n     -    ! (printf \"$sss$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null)\n     +    printf \"\" | git stripspace >tmp &&\n    -+    ! ( grep \" \" tmp >/dev/null) &&\n    ++    ! grep \" \" tmp >/dev/null &&\n     +    printf \"$sss\" | git stripspace >tmp &&\n    -+    ! ( grep \" \" tmp >/dev/null) &&\n    ++    ! grep \" \" tmp >/dev/null &&\n     +    printf \"$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \" \" tmp >/dev/null) &&\n    ++    ! grep \" \" tmp >/dev/null &&\n     +    printf \"$sss$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \" \" tmp >/dev/null) &&\n    ++    ! grep \" \" tmp >/dev/null &&\n     +    printf \"$sss$sss$sss$sss\" | git stripspace >tmp &&\n    -+    ! (grep \" \" tmp >/dev/null)\n    ++    ! grep \" \" tmp >/dev/null\n      '\n      \n      test_expect_success \\\n-- \n2.25.1\n\n"},{"id":"449694","messageId":"20220227122453.25278-2-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220227122453.25278-1-shivam828787@gmail.com","subject":"[PATCH v2 1/2] t0001-t0028: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-27T12:24:52Z","receivedAt":"2022-02-27T12:26:21Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0000-basic.sh            | 10 ++++++----\n t/t0022-crlf-rename.sh      |  4 ++--\n t/t0025-crlf-renormalize.sh |  4 ++--\n t/t0027-auto-crlf.sh        | 12 ++++++------\n 4 files changed, 16 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex b007f0efef..b5fa76059b 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '\n \tmv path2 path0 &&\n \tmv tmp path2 &&\n \tgit update-index --add --replace path2 path0/file2 &&\n-\tnumpath0=$(git ls-files path0 | wc -l) &&\n+\tgit ls-files path0 >tmp &&\n+\tnumpath0=$(wc -l <tmp) &&\n \ttest $numpath0 = 1\n '\n \n@@ -1104,12 +1105,13 @@ test_expect_success 'very long name in the index handled sanely' '\n \t>path4 &&\n \tgit update-index --add path4 &&\n \t(\n-\t\tgit ls-files -s path4 |\n-\t\tsed -e \"s/\t.*/\t/\" |\n+\t\tgit ls-files -s path4 >tmp &&\n+\t\tsed -e \"s/\t.*/\t/\" tmp |\n \t\ttr -d \"\\012\" &&\n \t\techo \"$a\"\n \t) | git update-index --index-info &&\n-\tlen=$(git ls-files \"a*\" | wc -c) &&\n+\tgit ls-files \"a*\" >tmp &&\n+\tlen=$(wc -c <tmp) &&\n \ttest $len = 4098\n '\n \ndiff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh\nindex c1a331e9e9..9fe9891251 100755\n--- a/t/t0022-crlf-rename.sh\n+++ b/t/t0022-crlf-rename.sh\n@@ -24,8 +24,8 @@ test_expect_success setup '\n \n test_expect_success 'diff -M' '\n \n-\tgit diff-tree -M -r --name-status HEAD^ HEAD |\n-\tsed -e \"s/R[0-9]*/RNUM/\" >actual &&\n+\tgit diff-tree -M -r --name-status HEAD^ HEAD >tmp &&\n+\tsed -e \"s/R[0-9]*/RNUM/\" tmp >actual &&\n \techo \"RNUM\tsample\telpmas\" >expect &&\n \ttest_cmp expect actual\n \ndiff --git a/t/t0025-crlf-renormalize.sh b/t/t0025-crlf-renormalize.sh\nindex 81447978b7..f7202c192e 100755\n--- a/t/t0025-crlf-renormalize.sh\n+++ b/t/t0025-crlf-renormalize.sh\n@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '\n \ti/lf w/lf attr/text=auto LF.txt\n \ti/lf w/mixed attr/text=auto CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol |\n-\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol >tmp &&\n+\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex c5f7ac63b0..0feb41a23f 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -311,8 +311,8 @@ checkout_files () {\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n \t\tEOF\n-\t\tgit ls-files --eol crlf_false_attr__* |\n-\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\t\tgit ls-files --eol crlf_false_attr__* >tmp &&\n+\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '\n \ti/ w/crlf TeBi_126_CL\n \ti/ w/-text TeBi_126_CLC\n \tEOF\n-\tgit ls-files --eol -o |\n+\tgit ls-files --eol -o >tmp &&\n \tsed -n -e \"/TeBi_/{s!attr/[\t]*!!g\n \ts!\t! !g\n \ts!  *! !g\n \tp\n-\t}\" | sort >actual &&\n+\t}\" tmp | sort >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -617,8 +617,8 @@ test_expect_success 'ls-files --eol -d -z' '\n \ti/lf w/ crlf_false_attr__LF.txt\n \ti/mixed w/ crlf_false_attr__CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol -d |\n-\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol -d >tmp &&\n+\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.25.1\n\n"},{"id":"449695","messageId":"20220227122453.25278-3-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220227122453.25278-1-shivam828787@gmail.com","subject":"[PATCH v2 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-02-27T12:24:53Z","receivedAt":"2022-02-27T12:26:26Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0030-stripspace.sh | 75 +++++++++++++++++++++++++++----------------\n t/t0050-filesystem.sh |  3 +-\n 2 files changed, 50 insertions(+), 28 deletions(-)\n\ndiff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\nindex ae1ca380c1..7bc3dcd07c 100755\n--- a/t/t0030-stripspace.sh\n+++ b/t/t0030-stripspace.sh\n@@ -13,6 +13,10 @@ s40='                                        '\n sss=\"$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40\" # 400\n ttt=\"$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40\" # 400\n \n+printf_git_stripspace () {\n+    printf \"$1\" | git stripspace\n+}\n+\n test_expect_success \\\n     'long lines without spaces should be unchanged' '\n     echo \"$ttt\" >expect &&\n@@ -225,32 +229,38 @@ test_expect_success \\\n \n test_expect_success \\\n     'text without newline at end should end with newline' '\n-    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$ttt\"\n '\n \n # text plus spaces at the end:\n \n test_expect_success \\\n     'text plus spaces without newline at end should end with newline' '\n-    test $(printf \"$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss$sss\" | git stripspace | wc -l) -gt 0\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss$sss\"\n '\n \n test_expect_success \\\n     'text plus spaces without newline at end should not show spaces' '\n-    ! (printf \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    printf \"$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$sss\" | git stripspace &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$sss$sss\" | git stripspace &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n+    ! grep \"  \" tmp >/dev/null\n '\n \n test_expect_success \\\n@@ -282,12 +292,18 @@ test_expect_success \\\n \n test_expect_success \\\n     'text plus spaces at end should not show spaces' '\n-    ! (echo \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    echo \"$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp>/dev/null &&\n+    echo \"$ttt$ttt$ttt$sss\" &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null\n '\n \n test_expect_success \\\n@@ -339,11 +355,16 @@ test_expect_success \\\n \n test_expect_success \\\n     'spaces without newline at end should not show spaces' '\n-    ! (printf \"\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null)\n+    printf \"\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null\n '\n \n test_expect_success \\\ndiff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\nindex afc343cf9b..5c9dc90d0b 100755\n--- a/t/t0050-filesystem.sh\n+++ b/t/t0050-filesystem.sh\n@@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '\n \trm camelcase &&\n \techo 1 >CamelCase &&\n \tgit add CamelCase &&\n-\tcamel=$(git ls-files | grep -i camelcase) &&\n+\tgit ls-files >tmp &&\n+\tcamel=$(grep -i camelcase tmp) &&\n \ttest $(echo \"$camel\" | wc -l) = 1 &&\n \ttest \"z$(git cat-file blob :$camel)\" = z1\n '\n-- \n2.25.1\n\n"},{"id":"449700","messageId":"177b8b40-9e27-5019-c4df-772642508c37@kdbg.org","threadId":"57467","inReplyTo":"20220227122453.25278-2-shivam828787@gmail.com","subject":"Re: [PATCH v2 1/2] t0001-t0028: avoid pipes with Git on LHS","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-02-27T17:43:03Z","receivedAt":"2022-02-27T17:43:12Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 27.02.22 um 13:24 schrieb Shubham Mishra:\n> diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\n> index b007f0efef..b5fa76059b 100755\n> --- a/t/t0000-basic.sh\n> +++ b/t/t0000-basic.sh\n\n> @@ -1104,12 +1105,13 @@ test_expect_success 'very long name in the index handled sanely' '\n>  \t>path4 &&\n>  \tgit update-index --add path4 &&\n>  \t(\n> -\t\tgit ls-files -s path4 |\n> -\t\tsed -e \"s/\t.*/\t/\" |\n> +\t\tgit ls-files -s path4 >tmp &&\n> +\t\tsed -e \"s/\t.*/\t/\" tmp |\n>  \t\ttr -d \"\\012\" &&\n>  \t\techo \"$a\"\n>  \t) | git update-index --index-info &&\n\nWe see a pipe here, and in the upstream of that pipe is a git\ninvocation. That should be fixed, too. After the rewrite that you\nalready did here, it should be sufficient to move the git invocation\nbefore the parentheses.\n\n> -\tlen=$(git ls-files \"a*\" | wc -c) &&\n> +\tgit ls-files \"a*\" >tmp &&\n> +\tlen=$(wc -c <tmp) &&\n>  \ttest $len = 4098\n>  '\n\n-- Hannes\n"},{"id":"449701","messageId":"7e09ee3e-9ac6-e2ff-c6a4-3dd03303b576@kdbg.org","threadId":"57467","inReplyTo":"20220227122453.25278-3-shivam828787@gmail.com","subject":"Re: [PATCH v2 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-02-27T17:52:32Z","receivedAt":"2022-02-27T17:52:40Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 27.02.22 um 13:24 schrieb Shubham Mishra:\n>  test_expect_success \\\n>      'text plus spaces without newline at end should not show spaces' '\n> -    ! (printf \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n> +    printf \"$ttt$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    printf \"$ttt$ttt$sss\" | git stripspace &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    printf \"$ttt$sss$sss\" | git stripspace &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n> +    ! grep \"  \" tmp >/dev/null\n>  '\n\nYou forgot to redirect all but the first `git stripspace`.\n\n>  \n>  test_expect_success \\\n> @@ -282,12 +292,18 @@ test_expect_success \\\n>  \n>  test_expect_success \\\n>      'text plus spaces at end should not show spaces' '\n> -    ! (echo \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n> -    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n> +    echo \"$ttt$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp>/dev/null &&\n> +    echo \"$ttt$ttt$ttt$sss\" &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp >/dev/null &&\n> +    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n> +    ! grep \"  \" tmp >/dev/null\n>  '\n\nA superficial glance at the visual pattern formed by the new lines\nreveals immediately that there is something foul. And indeed, one of the\nrewritten cases misses `| git stripspace >tmp`.\n\n-- Hannes\n"},{"id":"450262","messageId":"CAC316V7s5xQWP13YrwSV3ekt8T5oAWxpkmXTBsjff7C1KFrHyQ@mail.gmail.com","threadId":"57467","inReplyTo":"177b8b40-9e27-5019-c4df-772642508c37@kdbg.org","subject":"Re: [PATCH v2 1/2] t0001-t0028: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-03-03T12:48:18Z","receivedAt":"2022-03-03T12:48:35Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"On Sun, Feb 27, 2022 at 11:13 PM Johannes Sixt <j6t@kdbg.org> wrote:\n\n\n> We see a pipe here, and in the upstream of that pipe is a git\n> invocation. That should be fixed, too. After the rewrite that you\n> already did here, it should be sufficient to move the git invocation\n> before the parentheses.\n\nI missed that pipe, Thanks for pointing it out and reviewing.\n\nSorry for responding late, I am in the middle of my exams, so I am\nhardly checking mails.\n\nThanks,\nShubham\n"},{"id":"451210","messageId":"20220312062126.31988-1-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220224054720.23996-1-shivam828787@gmail.com","subject":"[GSoC] [PATCH v3 0/2] avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-03-12T06:21:24Z","receivedAt":"2022-03-12T06:22:02Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"changes since v2:\n* t0000: remove git command out of subshell\n* t0030: fix missing redirections to \"tmp\" file\nShubham Mishra (2):\n  t0001-t0028: avoid pipes with Git on LHS\n  t0030-t0050: avoid pipes with Git on LHS\n\n t/t0000-basic.sh            | 10 +++--\n t/t0022-crlf-rename.sh      |  4 +-\n t/t0025-crlf-renormalize.sh |  4 +-\n t/t0027-auto-crlf.sh        | 12 +++---\n t/t0030-stripspace.sh       | 75 ++++++++++++++++++++++++-------------\n t/t0050-filesystem.sh       |  3 +-\n 6 files changed, 66 insertions(+), 42 deletions(-)\n\nRange-diff against v2:\n1:  2a219ace42 ! 1:  5e122c0acf t0001-t0028: avoid pipes with Git on LHS\n    @@ t/t0000-basic.sh: test_expect_success 'update-index D/F conflict' '\n      '\n      \n     @@ t/t0000-basic.sh: test_expect_success 'very long name in the index handled sanely' '\n    + \n      \t>path4 &&\n      \tgit update-index --add path4 &&\n    ++\tgit ls-files -s path4 >tmp &&\n      \t(\n     -\t\tgit ls-files -s path4 |\n     -\t\tsed -e \"s/\t.*/\t/\" |\n    -+\t\tgit ls-files -s path4 >tmp &&\n     +\t\tsed -e \"s/\t.*/\t/\" tmp |\n      \t\ttr -d \"\\012\" &&\n      \t\techo \"$a\"\n2:  c90fc271d9 ! 2:  c412380af3 t0030-t0050: avoid pipes with Git on LHS\n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     -    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n     +    printf \"$ttt$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n    -+    printf \"$ttt$ttt$sss\" | git stripspace &&\n    ++    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n    -+    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n    ++    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n    -+    printf \"$ttt$sss$sss\" | git stripspace &&\n    ++    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n    -+    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n    ++    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n    -+    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n    ++    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null\n      '\n      \n    @@ t/t0030-stripspace.sh: test_expect_success \\\n     +    echo \"$ttt$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n    -+    ! grep \"  \" tmp>/dev/null &&\n    -+    echo \"$ttt$ttt$ttt$sss\" &&\n    ++    ! grep \"  \" tmp >/dev/null &&\n    ++    echo \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n     +    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n     +    ! grep \"  \" tmp >/dev/null &&\n-- \n2.25.1\n\n"},{"id":"451211","messageId":"20220312062126.31988-2-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220312062126.31988-1-shivam828787@gmail.com","subject":"[PATCH v3 1/2] t0001-t0028: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-03-12T06:21:25Z","receivedAt":"2022-03-12T06:22:08Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0000-basic.sh            | 10 ++++++----\n t/t0022-crlf-rename.sh      |  4 ++--\n t/t0025-crlf-renormalize.sh |  4 ++--\n t/t0027-auto-crlf.sh        | 12 ++++++------\n 4 files changed, 16 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex b007f0efef..9dcbf518a7 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -1089,7 +1089,8 @@ test_expect_success 'update-index D/F conflict' '\n \tmv path2 path0 &&\n \tmv tmp path2 &&\n \tgit update-index --add --replace path2 path0/file2 &&\n-\tnumpath0=$(git ls-files path0 | wc -l) &&\n+\tgit ls-files path0 >tmp &&\n+\tnumpath0=$(wc -l <tmp) &&\n \ttest $numpath0 = 1\n '\n \n@@ -1103,13 +1104,14 @@ test_expect_success 'very long name in the index handled sanely' '\n \n \t>path4 &&\n \tgit update-index --add path4 &&\n+\tgit ls-files -s path4 >tmp &&\n \t(\n-\t\tgit ls-files -s path4 |\n-\t\tsed -e \"s/\t.*/\t/\" |\n+\t\tsed -e \"s/\t.*/\t/\" tmp |\n \t\ttr -d \"\\012\" &&\n \t\techo \"$a\"\n \t) | git update-index --index-info &&\n-\tlen=$(git ls-files \"a*\" | wc -c) &&\n+\tgit ls-files \"a*\" >tmp &&\n+\tlen=$(wc -c <tmp) &&\n \ttest $len = 4098\n '\n \ndiff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh\nindex c1a331e9e9..9fe9891251 100755\n--- a/t/t0022-crlf-rename.sh\n+++ b/t/t0022-crlf-rename.sh\n@@ -24,8 +24,8 @@ test_expect_success setup '\n \n test_expect_success 'diff -M' '\n \n-\tgit diff-tree -M -r --name-status HEAD^ HEAD |\n-\tsed -e \"s/R[0-9]*/RNUM/\" >actual &&\n+\tgit diff-tree -M -r --name-status HEAD^ HEAD >tmp &&\n+\tsed -e \"s/R[0-9]*/RNUM/\" tmp >actual &&\n \techo \"RNUM\tsample\telpmas\" >expect &&\n \ttest_cmp expect actual\n \ndiff --git a/t/t0025-crlf-renormalize.sh b/t/t0025-crlf-renormalize.sh\nindex 81447978b7..f7202c192e 100755\n--- a/t/t0025-crlf-renormalize.sh\n+++ b/t/t0025-crlf-renormalize.sh\n@@ -22,8 +22,8 @@ test_expect_success 'renormalize CRLF in repo' '\n \ti/lf w/lf attr/text=auto LF.txt\n \ti/lf w/mixed attr/text=auto CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol |\n-\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol >tmp &&\n+\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh\nindex c5f7ac63b0..0feb41a23f 100755\n--- a/t/t0027-auto-crlf.sh\n+++ b/t/t0027-auto-crlf.sh\n@@ -311,8 +311,8 @@ checkout_files () {\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__CRLF_nul.txt\n \t\ti/-text w/$(stats_ascii $crlfnul) attr/$(attr_ascii $attr $aeol) crlf_false_attr__LF_nul.txt\n \t\tEOF\n-\t\tgit ls-files --eol crlf_false_attr__* |\n-\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\t\tgit ls-files --eol crlf_false_attr__* >tmp &&\n+\t\tsed -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \t\tsort >actual &&\n \t\ttest_cmp expect actual\n \t'\n@@ -359,12 +359,12 @@ test_expect_success 'ls-files --eol -o Text/Binary' '\n \ti/ w/crlf TeBi_126_CL\n \ti/ w/-text TeBi_126_CLC\n \tEOF\n-\tgit ls-files --eol -o |\n+\tgit ls-files --eol -o >tmp &&\n \tsed -n -e \"/TeBi_/{s!attr/[\t]*!!g\n \ts!\t! !g\n \ts!  *! !g\n \tp\n-\t}\" | sort >actual &&\n+\t}\" tmp | sort >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -617,8 +617,8 @@ test_expect_success 'ls-files --eol -d -z' '\n \ti/lf w/ crlf_false_attr__LF.txt\n \ti/mixed w/ crlf_false_attr__CRLF_mix_LF.txt\n \tEOF\n-\tgit ls-files --eol -d |\n-\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" |\n+\tgit ls-files --eol -d >tmp &&\n+\tsed -e \"s!attr/[^\t]*!!g\" -e \"s/\t/ /g\" -e \"s/  */ /g\" tmp |\n \tsort >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.25.1\n\n"},{"id":"451212","messageId":"20220312062126.31988-3-shivam828787@gmail.com","threadId":"57467","inReplyTo":"20220312062126.31988-1-shivam828787@gmail.com","subject":"[PATCH v3 2/2] t0030-t0050: avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-03-12T06:21:26Z","receivedAt":"2022-03-12T06:22:11Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"Pipes ignore error codes of LHS command and thus we should not use\nthem with Git in tests. As an alternative, use a 'tmp' file to write\nthe Git output so we can test the exit code.\n\nSigned-off-by: Shubham Mishra <shivam828787@gmail.com>\n---\n t/t0030-stripspace.sh | 75 +++++++++++++++++++++++++++----------------\n t/t0050-filesystem.sh |  3 +-\n 2 files changed, 50 insertions(+), 28 deletions(-)\n\ndiff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\nindex ae1ca380c1..0a5713c524 100755\n--- a/t/t0030-stripspace.sh\n+++ b/t/t0030-stripspace.sh\n@@ -13,6 +13,10 @@ s40='                                        '\n sss=\"$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40\" # 400\n ttt=\"$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40\" # 400\n \n+printf_git_stripspace () {\n+    printf \"$1\" | git stripspace\n+}\n+\n test_expect_success \\\n     'long lines without spaces should be unchanged' '\n     echo \"$ttt\" >expect &&\n@@ -225,32 +229,38 @@ test_expect_success \\\n \n test_expect_success \\\n     'text without newline at end should end with newline' '\n-    test $(printf \"$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$ttt\" | git stripspace | wc -l) -gt 0\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$ttt\"\n '\n \n # text plus spaces at the end:\n \n test_expect_success \\\n     'text plus spaces without newline at end should end with newline' '\n-    test $(printf \"$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$ttt$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$ttt$sss$sss\" | git stripspace | wc -l) -gt 0 &&\n-    test $(printf \"$ttt$sss$sss$sss\" | git stripspace | wc -l) -gt 0\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$ttt$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$ttt$sss$sss\" &&\n+    test_stdout_line_count -gt 0 printf_git_stripspace \"$ttt$sss$sss$sss\"\n '\n \n test_expect_success \\\n     'text plus spaces without newline at end should not show spaces' '\n-    ! (printf \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    printf \"$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null\n '\n \n test_expect_success \\\n@@ -282,12 +292,18 @@ test_expect_success \\\n \n test_expect_success \\\n     'text plus spaces at end should not show spaces' '\n-    ! (echo \"$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$ttt$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$ttt$sss$sss\" | git stripspace | grep \"  \" >/dev/null) &&\n-    ! (echo \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n+    echo \"$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null &&\n+    echo \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \"  \" tmp >/dev/null\n '\n \n test_expect_success \\\n@@ -339,11 +355,16 @@ test_expect_success \\\n \n test_expect_success \\\n     'spaces without newline at end should not show spaces' '\n-    ! (printf \"\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null) &&\n-    ! (printf \"$sss$sss$sss$sss\" | git stripspace | grep \" \" >/dev/null)\n+    printf \"\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null &&\n+    printf \"$sss$sss$sss$sss\" | git stripspace >tmp &&\n+    ! grep \" \" tmp >/dev/null\n '\n \n test_expect_success \\\ndiff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\nindex afc343cf9b..5c9dc90d0b 100755\n--- a/t/t0050-filesystem.sh\n+++ b/t/t0050-filesystem.sh\n@@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '\n \trm camelcase &&\n \techo 1 >CamelCase &&\n \tgit add CamelCase &&\n-\tcamel=$(git ls-files | grep -i camelcase) &&\n+\tgit ls-files >tmp &&\n+\tcamel=$(grep -i camelcase tmp) &&\n \ttest $(echo \"$camel\" | wc -l) = 1 &&\n \ttest \"z$(git cat-file blob :$camel)\" = z1\n '\n-- \n2.25.1\n\n"},{"id":"451215","messageId":"d13532cb-4f7d-d211-ff5c-26f90bd1c859@kdbg.org","threadId":"57467","inReplyTo":"20220312062126.31988-1-shivam828787@gmail.com","subject":"Re: [GSoC] [PATCH v3 0/2] avoid pipes with Git on LHS","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2022-03-12T09:05:07Z","receivedAt":"2022-03-12T09:05:14Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 12.03.22 um 07:21 schrieb Shubham Mishra:\n> changes since v2:\n> * t0000: remove git command out of subshell\n> * t0030: fix missing redirections to \"tmp\" file\n> Shubham Mishra (2):\n>   t0001-t0028: avoid pipes with Git on LHS\n>   t0030-t0050: avoid pipes with Git on LHS\n> \n>  t/t0000-basic.sh            | 10 +++--\n>  t/t0022-crlf-rename.sh      |  4 +-\n>  t/t0025-crlf-renormalize.sh |  4 +-\n>  t/t0027-auto-crlf.sh        | 12 +++---\n>  t/t0030-stripspace.sh       | 75 ++++++++++++++++++++++++-------------\n>  t/t0050-filesystem.sh       |  3 +-\n>  6 files changed, 66 insertions(+), 42 deletions(-)\n> \n> Range-diff against v2:\n> 1:  2a219ace42 ! 1:  5e122c0acf t0001-t0028: avoid pipes with Git on LHS\n>     @@ t/t0000-basic.sh: test_expect_success 'update-index D/F conflict' '\n>       '\n>       \n>      @@ t/t0000-basic.sh: test_expect_success 'very long name in the index handled sanely' '\n>     + \n>       \t>path4 &&\n>       \tgit update-index --add path4 &&\n>     ++\tgit ls-files -s path4 >tmp &&\n>       \t(\n>      -\t\tgit ls-files -s path4 |\n>      -\t\tsed -e \"s/\t.*/\t/\" |\n>     -+\t\tgit ls-files -s path4 >tmp &&\n>      +\t\tsed -e \"s/\t.*/\t/\" tmp |\n>       \t\ttr -d \"\\012\" &&\n>       \t\techo \"$a\"\n> 2:  c90fc271d9 ! 2:  c412380af3 t0030-t0050: avoid pipes with Git on LHS\n>     @@ t/t0030-stripspace.sh: test_expect_success \\\n>      -    ! (printf \"$ttt$sss$sss$sss\" | git stripspace | grep \"  \" >/dev/null)\n>      +    printf \"$ttt$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>     -+    printf \"$ttt$ttt$sss\" | git stripspace &&\n>     ++    printf \"$ttt$ttt$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>     -+    printf \"$ttt$ttt$ttt$sss\" | git stripspace &&\n>     ++    printf \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>     -+    printf \"$ttt$sss$sss\" | git stripspace &&\n>     ++    printf \"$ttt$sss$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>     -+    printf \"$ttt$ttt$sss$sss\" | git stripspace &&\n>     ++    printf \"$ttt$ttt$sss$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>     -+    printf \"$ttt$sss$sss$sss\" | git stripspace &&\n>     ++    printf \"$ttt$sss$sss$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null\n>       '\n>       \n>     @@ t/t0030-stripspace.sh: test_expect_success \\\n>      +    echo \"$ttt$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>      +    echo \"$ttt$ttt$sss\" | git stripspace >tmp &&\n>     -+    ! grep \"  \" tmp>/dev/null &&\n>     -+    echo \"$ttt$ttt$ttt$sss\" &&\n>     ++    ! grep \"  \" tmp >/dev/null &&\n>     ++    echo \"$ttt$ttt$ttt$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n>      +    echo \"$ttt$sss$sss\" | git stripspace >tmp &&\n>      +    ! grep \"  \" tmp >/dev/null &&\n\nThis round addresses all my comments. Thanks!\n\n-- Hannes\n"},{"id":"451216","messageId":"CAC316V4okGw37-mBeprtvHX_g4==DXLsTpuYY5rdFDrV0H-PEg@mail.gmail.com","threadId":"57467","inReplyTo":"d13532cb-4f7d-d211-ff5c-26f90bd1c859@kdbg.org","subject":"Re: [GSoC] [PATCH v3 0/2] avoid pipes with Git on LHS","fromName":"Shubham Mishra","fromEmail":"shivam828787@gmail.com","sentAt":"2022-03-12T10:27:22Z","receivedAt":"2022-03-12T10:27:55Z","isPatch":true,"sender":{"key":"shivam828787@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42690084?v=4"},"body":"> This round addresses all my comments. Thanks!\n>\nThanks, this series really helped me learn how code reviewing works here :).\nlooking forward to picking other tasks.\n\nThanks,\nShubham\n"}]}