{"thread":{"id":"62285","subject":"[Outreachy][PATCH] t6050: avoid pipes in git related commands","startedAt":"2024-10-08T16:21:33Z","lastAt":"2024-10-22T16:48:24Z","messageCount":25,"participants":["chizobajames21@gmail.com","Patrick Steinhardt","Chizoba ODINAKA","Phillip Wood","phillip.wood123@gmail.com","Junio C Hamano","Eric Sunshine","Taylor Blau"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"504456","messageId":"20241008162117.6452-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":null,"subject":"[Outreachy][PATCH] t6050: avoid pipes in git related commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-08T16:21:17Z","receivedAt":"2024-10-08T16:21:33Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe downstream command. For more accurate info on exit code tests,\nwrite output of upstreams into a file.\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\n t/t6050-replace.sh | 86 +++++++++++++++++++++++-----------------------\n 1 file changed, 43 insertions(+), 43 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..6b9811ed67 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,30 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual && grep \"author A U Thor\" actual &&\n+\tR=$(git cat-file commit $HASH2 >actual && sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual && grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual && grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual && grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual && grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual && grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual && grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual && grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual && grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual && grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual && grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual && grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +148,14 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual && grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual && grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual && grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual && grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +169,13 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual && grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual && grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +186,7 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual && grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +209,10 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual && grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual && git apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +225,7 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual && grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +234,23 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual && grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual && grep \"author A U Thor\" actual &&\n+\tS=$(git cat-file commit $PARA3 >actual && sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual && grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual && grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual && grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual && grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual && grep \"A U Thor\" actual\n \t)\n '\n \n@@ -284,8 +284,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +319,7 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual && grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +344,7 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >actual && sort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +356,7 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >actual && sort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +374,12 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual && grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual && grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual && grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual && grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +387,8 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual && grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual && grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +468,7 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual && grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"504525","messageId":"ZwYwm2-ixmyYVqo8@pks.im","threadId":"62285","inReplyTo":"20241008162117.6452-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH] t6050: avoid pipes in git related commands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-09T07:28:33Z","receivedAt":"2024-10-09T07:28:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Oct 08, 2024 at 05:21:17PM +0100, chizobajames21@gmail.com wrote:\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> \n> In pipes, the exit code of a chain of commands is determined by\n> the downstream command. For more accurate info on exit code tests,\n> write output of upstreams into a file.\n\nNit: it isn't really about accuracy, but rather about losing the return\ncode entirely. I'd also mention as part of your observation that t6050\nstill contains this pattern, which isn't currently obvious from just\nreading the commit message standalone.\n\nI'd also propose the following subject: \"t6050: avoid pipes with\ndownstream Git commands\", which reflects the fact that Git commands can\nbe at the end of the pipe without much of an issue.\n\n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> ---\n>  t/t6050-replace.sh | 86 +++++++++++++++++++++++-----------------------\n>  1 file changed, 43 insertions(+), 43 deletions(-)\n> \n> diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> index d7702fc756..6b9811ed67 100755\n> --- a/t/t6050-replace.sh\n> +++ b/t/t6050-replace.sh\n> @@ -98,30 +98,30 @@ test_expect_success 'set up buggy branch' '\n>  '\n>  \n>  test_expect_success 'replace the author' '\n> -\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> -\tgit cat-file commit $R | grep \"author O Thor\" &&\n> +\tgit cat-file commit $HASH2 >actual && grep \"author A U Thor\" actual &&\n> +\tR=$(git cat-file commit $HASH2 >actual && sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> +\tgit cat-file commit $R >actual && grep \"author O Thor\" actual &&\n> \n>  \tgit update-ref refs/replace/$HASH2 $R &&\n> -\tgit show HEAD~5 | grep \"O Thor\" &&\n> -\tgit show $HASH2 | grep \"O Thor\"\n> +\tgit show HEAD~5 >actual && grep \"O Thor\" actual &&\n> +\tgit show $HASH2 >actual && grep \"O Thor\" actual\n>  '\n\nWe don't typically chain multiple commands on the same line, as it\nbecomes hard to read very fast. So these should all be split across\nmultiple lines. The same is true for other tests you have converted.\n\nFurthermore, I'd recommend to replace \"grep\" with \"test_grep\", which is\na convenience wrapper that provides more context in case the grep might\nhave failed. It would for example output the contents of \"actual\", which\nhelps quite a lot in the context of failing CI jobs.\n\nThanks!\n\nPatrick\n"},{"id":"504676","messageId":"20241010063906.51767-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"20241008162117.6452-1-chizobajames21@gmail.com","subject":"[Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-10T06:39:06Z","receivedAt":"2024-10-10T06:39:15Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe downstream command. In order not to loss the entire result code of tests,\nwrite output of upstreams into a file.\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nChanges in v2:\n- split multiple commands chain on the same line across multiple line,\n  for easier readability\n- replace \"grep\" with \"test_grep\", for more context in case of a \"grep\"\n  failure\n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 87 insertions(+), 46 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..599b6bc66c 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,43 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +161,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +186,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +205,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +229,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +247,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +257,31 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +291,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\t! test_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,7 +315,7 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n \tgit --no-replace-objects pack-objects test- &&\n \tgit index-pack test-*.pack\n '\n@@ -319,7 +350,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +376,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >actual &&\n+\tsort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +389,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >actual &&\n+\tsort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +408,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +425,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +508,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"504682","messageId":"CACwP9ar1MtZYK06RsRre5d7Zo-OtNdUvqFwpxjcHVvYuzWS4Dg@mail.gmail.com","threadId":"62285","inReplyTo":"ZwYwm2-ixmyYVqo8@pks.im","subject":"Re: [Outreachy][PATCH] t6050: avoid pipes in git related commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-10T07:26:19Z","receivedAt":"2024-10-10T07:26:32Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"On Wed, 9 Oct 2024 at 08:28, Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Tue, Oct 08, 2024 at 05:21:17PM +0100, chizobajames21@gmail.com wrote:\n> > From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> >\n> > In pipes, the exit code of a chain of commands is determined by\n> > the downstream command. For more accurate info on exit code tests,\n> > write output of upstreams into a file.\n>\n> Nit: it isn't really about accuracy, but rather about losing the return\n> code entirely. I'd also mention as part of your observation that t6050\n> still contains this pattern, which isn't currently obvious from just\n> reading the commit message standalone.\n>\nThanks Patrick for the review, and for pointing this out, I totally\nagree with you.\n> I'd also propose the following subject: \"t6050: avoid pipes with\n> downstream Git commands\", which reflects the fact that Git commands can\n> be at the end of the pipe without much of an issue.\n>\nAnd I will effect this proposal the next change.\n\n> > Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> > ---\n> >  t/t6050-replace.sh | 86 +++++++++++++++++++++++-----------------------\n> >  1 file changed, 43 insertions(+), 43 deletions(-)\n> >\n> > diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> > index d7702fc756..6b9811ed67 100755\n> > --- a/t/t6050-replace.sh\n> > +++ b/t/t6050-replace.sh\n> > @@ -98,30 +98,30 @@ test_expect_success 'set up buggy branch' '\n> >  '\n> >\n> >  test_expect_success 'replace the author' '\n> > -     git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     R=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> > -     git cat-file commit $R | grep \"author O Thor\" &&\n> > +     git cat-file commit $HASH2 >actual && grep \"author A U Thor\" actual &&\n> > +     R=$(git cat-file commit $HASH2 >actual && sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> > +     git cat-file commit $R >actual && grep \"author O Thor\" actual &&\n> >\n> >       git update-ref refs/replace/$HASH2 $R &&\n> > -     git show HEAD~5 | grep \"O Thor\" &&\n> > -     git show $HASH2 | grep \"O Thor\"\n> > +     git show HEAD~5 >actual && grep \"O Thor\" actual &&\n> > +     git show $HASH2 >actual && grep \"O Thor\" actual\n> >  '\n>\n> We don't typically chain multiple commands on the same line, as it\n> becomes hard to read very fast. So these should all be split across\n> multiple lines. The same is true for other tests you have converted.\n>\n> Furthermore, I'd recommend to replace \"grep\" with \"test_grep\", which is\n> a convenience wrapper that provides more context in case the grep might\n> have failed. It would for example output the contents of \"actual\", which\n> helps quite a lot in the context of failing CI jobs.\n>\nI made these recommended changes.\n> Thanks!\n>\n> Patrick\n\nThank you.\nChizoba\n"},{"id":"504698","messageId":"90dea722-0762-4a37-a216-6883f4889c67@gmail.com","threadId":"62285","inReplyTo":"20241010063906.51767-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commands","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-10-10T14:08:16Z","receivedAt":"2024-10-10T14:08:20Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Chizoba\n\nOn 10/10/2024 07:39, chizobajames21@gmail.com wrote:\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> \n> In pipes, the exit code of a chain of commands is determined by\n> the downstream command.\n\nI would perhaps say \"final command\" rather than \"downstream command\" as \nin a pipeline \"cmd1 | cmd2 | cmd3\" cmd2 and cmd3 are downstream of cmd1 \nbut it is the exit code of cmd3 that will be used\n\n> In order not to loss the entire result code of tests,\n> write output of upstreams into a file.\n\nWe're interested in checking the exit code of git, but not other \ncommands so it would be helpful to make that clear. Usman's patch [1] \nhas a good explanation of this.\n\nThis patch also changes instances of \"grep\" to \"test_grep\" so the commit \nmessage needs to explain the reason for that change which is that it \ngives a better debugging experience if the test fails.\n\nThe patch is looking pretty good, most of the conversions look correct. \nI've left a few comments below\n\n\n[1] \nhttps://lore.kernel.org/git/bfff7937cd20737bb5a8791dc7492700b1d7881f.1728315124.git.gitgitgadget@gmail.com\n\n>   test_expect_success 'replace the author' '\n> -\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> -\tgit cat-file commit $R | grep \"author O Thor\" &&\n> +\tgit cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tgit cat-file commit $HASH2 >actual &&\n\nYou don't need to repeat this command now that we are saving the output \nof \"git cat-file commit $HASH2\"\n\n> +\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> +\tgit cat-file commit $R >actual &&\n> +\ttest_grep \"author O Thor\" actual &&\n\n>   test_expect_success 'push branch with replacement' '\n> -\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n> -\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> -\tgit cat-file commit $S | grep \"author O Thor\" &&\n> +\tgit cat-file commit $PARA3 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tgit cat-file commit $PARA3 >actual &&\n\nWe can drop this line for the same reason as above\n\n> +\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> +\tgit cat-file commit $S >actual &&\n> +\ttest_grep \"author O Thor\" actual &&\n\n> @@ -260,14 +291,14 @@ test_expect_success 'fetch branch with replacement' '\n>   \t\tcd clone_dir &&\n>   \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n>   \t\tgit log --pretty=oneline parallel3 >output.txt &&\n> -\t\t! grep $PARA3 output.txt &&\n> +\t\t! test_grep $PARA3 output.txt &&\n\ntest_grep will print an error message the pattern does not match. In \nthis case we expect it not to match so we want to print an error if it \ndoes match. We can do that with\n\n\ttest_grep ! $PARA3 output.txt &&\n\n>   test_expect_success 'index-pack and replacements' '\n> -\tgit --no-replace-objects rev-list --objects HEAD |\n> +\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n>   \tgit --no-replace-objects pack-objects test- &&\n\nThis command has lost its input - you need to use '<actual' to get it to \nread output from \"git rev-list\". This test itself could probably do a \nbetter job of checking that index-pack does what we expect but that is \noutside the scope of this patch.\n\n>   \tgit index-pack test-*.pack\n>   '\n\nEverything that I've not commented on looks correct to me.\n\nBest Wishes\n\nPhillip\n"},{"id":"504733","messageId":"CACwP9aqEoRchNN-4iuSxrhtt5k-yHMsjmyQjaG9uV4xUsQ7geg@mail.gmail.com","threadId":"62285","inReplyTo":"90dea722-0762-4a37-a216-6883f4889c67@gmail.com","subject":"Re: [Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-10T18:51:31Z","receivedAt":"2024-10-10T18:51:45Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"Hi Philip,\nOn Thu, 10 Oct 2024 at 15:08, Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> Hi Chizoba\n>\n> On 10/10/2024 07:39, chizobajames21@gmail.com wrote:\n> > From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> >\n> > In pipes, the exit code of a chain of commands is determined by\n> > the downstream command.\n>\n> I would perhaps say \"final command\" rather than \"downstream command\" as\n> in a pipeline \"cmd1 | cmd2 | cmd3\" cmd2 and cmd3 are downstream of cmd1\n> but it is the exit code of cmd3 that will be used\n>\nYes, final command is a more appropriate explain.\n> > In order not to loss the entire result code of tests,\n> > write output of upstreams into a file.\n>\n> We're interested in checking the exit code of git, but not other\n> commands so it would be helpful to make that clear. Usman's patch [1]\n> has a good explanation of this.\n>\nI just read that sentence again, it obviously needs some clarity. \"In order not\nto miss the exit code of any Git command, avoid using pipe and write\noutput into a file\"\nhas more clarity. I will look up on Usman's patch [1], before my next changes.\n\n> This patch also changes instances of \"grep\" to \"test_grep\" so the commit\n> message needs to explain the reason for that change which is that it\n> gives a better debugging experience if the test fails.\n>\nI had included that in my \"Changes in v2\", appended beneath my \"Sign-off-by\".\n\"Changes in v2:\n- split multiple commands chain on the same line across multiple line,\n  for easier readability\n- replace \"grep\" with \"test_grep\", for more context in case of a \"grep\"\n  failure\"\nMaybe it was not so obvious that you didn't notice, or it is not the\ntraditional way of including it.\n\n> The patch is looking pretty good, most of the conversions look correct.\n> I've left a few comments below\n>\n>\n> [1]\n> https://lore.kernel.org/git/bfff7937cd20737bb5a8791dc7492700b1d7881f.1728315124.git.gitgitgadget@gmail.com\n>\n> >   test_expect_success 'replace the author' '\n> > -     git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     R=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> > -     git cat-file commit $R | grep \"author O Thor\" &&\n> > +     git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     git cat-file commit $HASH2 >actual &&\n>\n> You don't need to repeat this command now that we are saving the output\n> of \"git cat-file commit $HASH2\"\n>\n> > +     R=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> > +     git cat-file commit $R >actual &&\n> > +     test_grep \"author O Thor\" actual &&\n>\n> >   test_expect_success 'push branch with replacement' '\n> > -     git cat-file commit $PARA3 | grep \"author A U Thor\" &&\n> > -     S=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> > -     git cat-file commit $S | grep \"author O Thor\" &&\n> > +     git cat-file commit $PARA3 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     git cat-file commit $PARA3 >actual &&\n>\n> We can drop this line for the same reason as above\n>\n> > +     S=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> > +     git cat-file commit $S >actual &&\n> > +     test_grep \"author O Thor\" actual &&\n>\n> > @@ -260,14 +291,14 @@ test_expect_success 'fetch branch with replacement' '\n> >               cd clone_dir &&\n> >               git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n> >               git log --pretty=oneline parallel3 >output.txt &&\n> > -             ! grep $PARA3 output.txt &&\n> > +             ! test_grep $PARA3 output.txt &&\n>\n> test_grep will print an error message the pattern does not match. In\n> this case we expect it not to match so we want to print an error if it\n> does match. We can do that with\n>\n>         test_grep ! $PARA3 output.txt &&\n>\n> >   test_expect_success 'index-pack and replacements' '\n> > -     git --no-replace-objects rev-list --objects HEAD |\n> > +     git --no-replace-objects rev-list --objects HEAD >actual &&\n> >       git --no-replace-objects pack-objects test- &&\n>\n> This command has lost its input - you need to use '<actual' to get it to\n> read output from \"git rev-list\". This test itself could probably do a\n> better job of checking that index-pack does what we expect but that is\n> outside the scope of this patch.\n>\n> >       git index-pack test-*.pack\n> >   '\n>\n> Everything that I've not commented on looks correct to me.\n>\nThanks Philip for the review, I will make the needed changes in my\nnext patch. And look into\nthe index-pack proposal in a new patch, since it is outside this scope.\n> Best Wishes\n>\n> Phillip\n\nThanks\nChizoba\n"},{"id":"504831","messageId":"712557bd-f3f1-4489-95df-a55f90f1dbda@gmail.com","threadId":"62285","inReplyTo":"CACwP9aqEoRchNN-4iuSxrhtt5k-yHMsjmyQjaG9uV4xUsQ7geg@mail.gmail.com","subject":"Re: [Outreachy][PATCH v2] t6050: avoid pipes with downstream Git commands","fromName":"","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-10-11T09:17:46Z","receivedAt":"2024-10-11T09:17:49Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Chizoba\n\nOn 10/10/2024 19:51, Chizoba ODINAKA wrote:\n> On Thu, 10 Oct 2024 at 15:08, Phillip Wood <phillip.wood123@gmail.com> wrote:\n>> On 10/10/2024 07:39, chizobajames21@gmail.com wrote:\n>>> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n>>>\n>>> In order not to loss the entire result code of tests,\n>>> write output of upstreams into a file.\n>>\n>> We're interested in checking the exit code of git, but not other\n>> commands so it would be helpful to make that clear. Usman's patch [1]\n>> has a good explanation of this.\n>>\n> I just read that sentence again, it obviously needs some clarity. \"In order not\n> to miss the exit code of any Git command, avoid using pipe and write\n> output into a file\"\n> has more clarity. I will look up on Usman's patch [1], before my next changes.\n> \n>> This patch also changes instances of \"grep\" to \"test_grep\" so the commit\n>> message needs to explain the reason for that change which is that it\n>> gives a better debugging experience if the test fails.\n>>\n> I had included that in my \"Changes in v2\", appended beneath my \"Sign-off-by\".\n> \"Changes in v2:\n> - split multiple commands chain on the same line across multiple line,\n>    for easier readability\n> - replace \"grep\" with \"test_grep\", for more context in case of a \"grep\"\n>    failure\"\n> Maybe it was not so obvious that you didn't notice, or it is not the\n> traditional way of including it.\n\nIt's great that you listed the changes between versions below the \"---\" \nline - that is really helpful for reviewers. However those comments are \nnot part of the commit message when the patch is applied. It is \nimportant for the commit message to explain the reasons for all the \nchanges in a patch so that someone reading it later can understand why \nthe change was made. Therefore the grep->test_grep change should be \nexplained in the commit message. In general one should avoid making \nunrelated changes in the same commit. In this case I think one can argue \nthat the changes are small enough that combining them is fine.\n\n> Thanks Philip for the review, I will make the needed changes in my\n> next patch.\n\nThat's great, I look forward to reviewing it\n\n> And look into\n> the index-pack proposal in a new patch, since it is outside this scope.\n\nLet's finish this patch first. I'm not sure what the best way to improve \nthat test is at the moment.\n\nBest Wishes\n\nPhillip\n"},{"id":"504838","messageId":"20241011154555.584917-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"20241010063906.51767-1-chizobajames21@gmail.com","subject":"[Outreachy][PATCH v3] t6050: avoid pipes with downstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-11T15:45:55Z","receivedAt":"2024-10-11T15:46:06Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nChanges in v3:\n- remove some duplicated lines of code\n- fixed some typo, an ommitted input redirection sign, <,\n  and another omitted logic negation operator, !\n\nRange-diff against v2:\n1:  a084472fa6 ! 1:  3ef388e9aa t6050: avoid pipes with downstream Git commands\n    @@ Commit message\n         t6050: avoid pipes with downstream Git commands\n     \n         In pipes, the exit code of a chain of commands is determined by\n    -    the downstream command. In order not to loss the entire result code of tests,\n    -    write output of upstreams into a file.\n    +    the final command. In order not to miss the exit code of a failed\n    +    Git command, avoid pipes instead write output of Git commands\n    +    into a file.\n    +    For better debugging experience, instances of \"grep\" were changed\n    +    to \"test_grep\". \"test_grep\" provides more context in case of a\n    +    failed \"grep\".\n     \n         Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n     \n    @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n     -\tgit cat-file commit $R | grep \"author O Thor\" &&\n     +\tgit cat-file commit $HASH2 >actual &&\n     +\ttest_grep \"author A U Thor\" actual &&\n    -+\tgit cat-file commit $HASH2 >actual &&\n     +\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n     +\tgit cat-file commit $R >actual &&\n     +\ttest_grep \"author O Thor\" actual &&\n    @@ t/t6050-replace.sh: test_expect_success 'push to cloned repo' '\n     -\tgit cat-file commit $S | grep \"author O Thor\" &&\n     +\tgit cat-file commit $PARA3 >actual &&\n     +\ttest_grep \"author A U Thor\" actual &&\n    -+\tgit cat-file commit $PARA3 >actual &&\n     +\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n     +\tgit cat-file commit $S >actual &&\n     +\ttest_grep \"author O Thor\" actual &&\n    @@ t/t6050-replace.sh: test_expect_success 'fetch branch with replacement' '\n      \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n      \t\tgit log --pretty=oneline parallel3 >output.txt &&\n     -\t\t! grep $PARA3 output.txt &&\n    -+\t\t! test_grep $PARA3 output.txt &&\n    ++\t\ttest_grep ! $PARA3 output.txt &&\n      \t\tgit show $PARA3 >para3.txt &&\n     -\t\tgrep \"A U Thor\" para3.txt &&\n     +\t\ttest_grep \"A U Thor\" para3.txt &&\n    @@ t/t6050-replace.sh: test_expect_success 'bisect and replacements' '\n      \n      test_expect_success 'index-pack and replacements' '\n     -\tgit --no-replace-objects rev-list --objects HEAD |\n    +-\tgit --no-replace-objects pack-objects test- &&\n     +\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n    - \tgit --no-replace-objects pack-objects test- &&\n    ++\tgit --no-replace-objects pack-objects test- <actual &&\n      \tgit index-pack test-*.pack\n      '\n    + \n     @@ t/t6050-replace.sh: test_expect_success '-f option bypasses the type check' '\n      '\n      \n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..f09055beac 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >actual &&\n+\tsort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >actual &&\n+\tsort actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"504840","messageId":"xmqq8quuiq4x.fsf@gitster.g","threadId":"62285","inReplyTo":"20241011154555.584917-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v3] t6050: avoid pipes with downstream Git commands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-10-11T16:02:54Z","receivedAt":"2024-10-11T16:02:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"chizobajames21@gmail.com writes:\n\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n>\n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n>\n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> ---\n> Changes in v3:\n> - remove some duplicated lines of code\n> - fixed some typo, an ommitted input redirection sign, <,\n>   and another omitted logic negation operator, !\n\nI'd suggest looking at your commit title again.  \"with downstream\nGit commands\" sounds like the git being tested is at the tail, not\nin front, of a pipeline, which would be perfectly OK arrangement to\nsee what its exit status is.\n\nThe updated patch does indeed use such a construct, e.g.\n\n> +\tgit cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n\nhere.\n\n    Subject: [Outreachy][PATCH v3] t6050: don't lose exit status of Git to pipes\n\nor something, perhaps.\n\nOther than that, looking very good.  Big thanks to all of you.\n\n"},{"id":"504841","messageId":"CAPig+cRLdzAEA-G=L81yR9dmm8Y-5VEU7ybyohKmbq9=0bDUaQ@mail.gmail.com","threadId":"62285","inReplyTo":"20241011154555.584917-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v3] t6050: avoid pipes with downstream Git commands","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2024-10-11T16:03:14Z","receivedAt":"2024-10-11T16:03:27Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Oct 11, 2024 at 11:46 AM <chizobajames21@gmail.com> wrote:\n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n>\n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> ---\n> diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n> -       git replace -l --format medium | sort >actual &&\n> +       git replace -l --format medium >actual &&\n> +       sort actual &&\n>         test_cmp expected actual\n\nIsn't this conversion broken? The `sort` command emits the sorted\ncontent to its standard output stream; it does not sort the file in\nplace. So this is doing the sort but then simply throwing the output\naway, not capturing it to a file for comparison via `test_cmp`.\n"},{"id":"504858","messageId":"xmqqzfnaedh6.fsf@gitster.g","threadId":"62285","inReplyTo":"CAPig+cRLdzAEA-G=L81yR9dmm8Y-5VEU7ybyohKmbq9=0bDUaQ@mail.gmail.com","subject":"Re: [Outreachy][PATCH v3] t6050: avoid pipes with downstream Git commands","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-10-11T17:49:57Z","receivedAt":"2024-10-11T17:50:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Fri, Oct 11, 2024 at 11:46 AM <chizobajames21@gmail.com> wrote:\n>> In pipes, the exit code of a chain of commands is determined by\n>> the final command. In order not to miss the exit code of a failed\n>> Git command, avoid pipes instead write output of Git commands\n>> into a file.\n>> For better debugging experience, instances of \"grep\" were changed\n>> to \"test_grep\". \"test_grep\" provides more context in case of a\n>> failed \"grep\".\n>>\n>> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n>> ---\n>> diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n>> @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n>> -       git replace -l --format medium | sort >actual &&\n>> +       git replace -l --format medium >actual &&\n>> +       sort actual &&\n>>         test_cmp expected actual\n>\n> Isn't this conversion broken? The `sort` command emits the sorted\n> content to its standard output stream; it does not sort the file in\n> place. So this is doing the sort but then simply throwing the output\n> away, not capturing it to a file for comparison via `test_cmp`.\n\nGood eyes.\n"},{"id":"504886","messageId":"20241011235959.596136-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"xmqqzfnaedh6.fsf@gitster.g","subject":"[Outreachy][PATCH v4] t6050: avoid pipes with upstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-11T23:59:59Z","receivedAt":"2024-10-12T00:00:08Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nChanges in v4:\n- Correct the subject\n- fixed some ommitted output option in sorts that where writing to\n  stdout\n\nRange-diff against v3:\n1:  3ef388e9aa ! 1:  28cab4c752 t6050: avoid pipes with downstream Git commands\n    @@ Metadata\n     Author: Chizoba ODINAKA <chizobajames21@gmail.com>\n     \n      ## Commit message ##\n    -    t6050: avoid pipes with downstream Git commands\n    +    t6050: avoid pipes with upstream Git commands\n     \n         In pipes, the exit code of a chain of commands is determined by\n         the final command. In order not to miss the exit code of a failed\n    @@ Commit message\n         failed \"grep\".\n     \n         Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n    +    Changes in v4:\n    +    - Correct the subject\n    +    - fixed some ommitted output option in sorts that where writing to\n    +      stdout\n     \n      ## t/t6050-replace.sh ##\n     @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n    @@ t/t6050-replace.sh: test_expect_success 'test --format medium' '\n      \t} | sort >expected &&\n     -\tgit replace -l --format medium | sort >actual &&\n     +\tgit replace -l --format medium >actual &&\n    -+\tsort actual &&\n    ++\tsort actual -o actual &&\n      \ttest_cmp expected actual\n      '\n      \n    @@ t/t6050-replace.sh: test_expect_success 'test --format long' '\n      \t} | sort >expected &&\n     -\tgit replace --format=long | sort >actual &&\n     +\tgit replace --format=long >actual &&\n    -+\tsort actual &&\n    ++\tsort actual -o actual &&\n      \ttest_cmp expected actual\n      '\n      \n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..018d672c1b 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >actual &&\n+\tsort actual -o actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >actual &&\n+\tsort actual -o actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"504900","messageId":"CAPig+cSRJXoZfXdBmWt8md78t-6c2NBjeR=PK=RaKqLoCjxXMw@mail.gmail.com","threadId":"62285","inReplyTo":"20241011235959.596136-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v4] t6050: avoid pipes with upstream Git commands","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2024-10-12T05:35:31Z","receivedAt":"2024-10-12T05:35:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Oct 11, 2024 at 8:00 PM <chizobajames21@gmail.com> wrote:\n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n>\n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> ---\n> diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n> -       git replace -l --format medium | sort >actual &&\n> +       git replace -l --format medium >actual &&\n> +       sort actual -o actual &&\n>         test_cmp expected actual\n\nAlthough `sort -o` is POSIX, it may not be supported by all platforms\non which Git is built. Moreover, as far as I can tell, `sort -o` is\nnot used at all in the Git test suite, so we should be wary of using\nit here. Therefore, rather than introducing a novel use of this\ncommand, which might possibly break on some platform, instead stick\nwith what is known to work without problem:\n\n    git replace -l --format medium >output &&\n    sort output >actual &&\n"},{"id":"504902","messageId":"20241012062126.603967-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"20241011235959.596136-1-chizobajames21@gmail.com","subject":"[Outreachy][PATCH v5] t6050: avoid pipes with upstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-12T06:21:26Z","receivedAt":"2024-10-12T06:21:37Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\nChanges in v5:\n- replace 'sort -o' which might not be supported by some platforms\n  to the more conventional output redirection, > .\n---\nRange-diff against v4:\n1:  28cab4c752 ! 1:  b339b1f550 t6050: avoid pipes with upstream Git commands\n    @@ Commit message\n         failed \"grep\".\n     \n         Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n    -    Changes in v4:\n    -    - Correct the subject\n    -    - fixed some ommitted output option in sorts that where writing to\n    -      stdout\n    +    Changes in v5:\n    +    - replace 'sort -o' which might not be supported by some platforms\n    +      to the more conventional output redirection, > .\n     \n      ## t/t6050-replace.sh ##\n     @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n    @@ t/t6050-replace.sh: test_expect_success 'test --format medium' '\n      \t\techo \"$MYTAG -> $HASH1\"\n      \t} | sort >expected &&\n     -\tgit replace -l --format medium | sort >actual &&\n    -+\tgit replace -l --format medium >actual &&\n    -+\tsort actual -o actual &&\n    ++\tgit replace -l --format medium >output &&\n    ++\tsort output >actual &&\n      \ttest_cmp expected actual\n      '\n      \n    @@ t/t6050-replace.sh: test_expect_success 'test --format long' '\n      \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n      \t} | sort >expected &&\n     -\tgit replace --format=long | sort >actual &&\n    -+\tgit replace --format=long >actual &&\n    -+\tsort actual -o actual &&\n    ++\tgit replace --format=long >output &&\n    ++\tsort output >actual &&\n      \ttest_cmp expected actual\n      '\n      \n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..37cb6547b6 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"504907","messageId":"CACwP9aoDGN_Oaw3-JyjyaH-jKO5wbFYhkeJrV4gTRr2TcRfE1g@mail.gmail.com","threadId":"62285","inReplyTo":"CAPig+cSRJXoZfXdBmWt8md78t-6c2NBjeR=PK=RaKqLoCjxXMw@mail.gmail.com","subject":"Re: [Outreachy][PATCH v4] t6050: avoid pipes with upstream Git commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-12T06:28:04Z","receivedAt":"2024-10-12T06:28:17Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"On Sat, 12 Oct 2024 at 06:35, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Fri, Oct 11, 2024 at 8:00 PM <chizobajames21@gmail.com> wrote:\n> > In pipes, the exit code of a chain of commands is determined by\n> > the final command. In order not to miss the exit code of a failed\n> > Git command, avoid pipes instead write output of Git commands\n> > into a file.\n> > For better debugging experience, instances of \"grep\" were changed\n> > to \"test_grep\". \"test_grep\" provides more context in case of a\n> > failed \"grep\".\n> >\n> > Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> > ---\n> > diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> > @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n> > -       git replace -l --format medium | sort >actual &&\n> > +       git replace -l --format medium >actual &&\n> > +       sort actual -o actual &&\n> >         test_cmp expected actual\n>\n> Although `sort -o` is POSIX, it may not be supported by all platforms\n> on which Git is built. Moreover, as far as I can tell, `sort -o` is\n> not used at all in the Git test suite, so we should be wary of using\n> it here. Therefore, rather than introducing a novel use of this\n> command, which might possibly break on some platform, instead stick\n> with what is known to work without problem:\n>\n>     git replace -l --format medium >output &&\n>     sort output >actual &&\n\nFixed. Thanks Eric.\n"},{"id":"505021","messageId":"879cac32-f59c-4adb-973e-4a8fc1770f8e@gmail.com","threadId":"62285","inReplyTo":"20241012062126.603967-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v5] t6050: avoid pipes with upstream Git commands","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2024-10-14T14:00:23Z","receivedAt":"2024-10-14T14:00:31Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Chizoba\n\nOn 12/10/2024 07:21, chizobajames21@gmail.com wrote:\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> \n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n> \n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> Changes in v5:\n> - replace 'sort -o' which might not be supported by some platforms\n>    to the more conventional output redirection, > .\n\nIt's really helpful to list the changes like this, but please do so \nbelow the \"---\" line so it does not become part of the commit message \nwhen the patch is applied. The range-diff looks good, with a fixed up \ncommit message I think we can declare victory for this microproject.\n\nBest Wishes\n\nPhillip\n\n> ---\n> Range-diff against v4:\n> 1:  28cab4c752 ! 1:  b339b1f550 t6050: avoid pipes with upstream Git commands\n>      @@ Commit message\n>           failed \"grep\".\n>       \n>           Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n>      -    Changes in v4:\n>      -    - Correct the subject\n>      -    - fixed some ommitted output option in sorts that where writing to\n>      -      stdout\n>      +    Changes in v5:\n>      +    - replace 'sort -o' which might not be supported by some platforms\n>      +      to the more conventional output redirection, > .\n>       \n>        ## t/t6050-replace.sh ##\n>       @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n>      @@ t/t6050-replace.sh: test_expect_success 'test --format medium' '\n>        \t\techo \"$MYTAG -> $HASH1\"\n>        \t} | sort >expected &&\n>       -\tgit replace -l --format medium | sort >actual &&\n>      -+\tgit replace -l --format medium >actual &&\n>      -+\tsort actual -o actual &&\n>      ++\tgit replace -l --format medium >output &&\n>      ++\tsort output >actual &&\n>        \ttest_cmp expected actual\n>        '\n>        \n>      @@ t/t6050-replace.sh: test_expect_success 'test --format long' '\n>        \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n>        \t} | sort >expected &&\n>       -\tgit replace --format=long | sort >actual &&\n>      -+\tgit replace --format=long >actual &&\n>      -+\tsort actual -o actual &&\n>      ++\tgit replace --format=long >output &&\n>      ++\tsort output >actual &&\n>        \ttest_cmp expected actual\n>        '\n>        \n> \n>   t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n>   1 file changed, 86 insertions(+), 47 deletions(-)\n> \n> diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> index d7702fc756..37cb6547b6 100755\n> --- a/t/t6050-replace.sh\n> +++ b/t/t6050-replace.sh\n> @@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n>   '\n>   \n>   test_expect_success 'replace the author' '\n> -\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> -\tgit cat-file commit $R | grep \"author O Thor\" &&\n> +\tgit cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> +\tgit cat-file commit $R >actual &&\n> +\ttest_grep \"author O Thor\" actual &&\n>   \tgit update-ref refs/replace/$HASH2 $R &&\n> -\tgit show HEAD~5 | grep \"O Thor\" &&\n> -\tgit show $HASH2 | grep \"O Thor\"\n> +\tgit show HEAD~5 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"O Thor\" actual\n>   '\n>   \n>   test_expect_success 'test --no-replace-objects option' '\n> -\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n> -\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tgit show $HASH2 | grep \"O Thor\" &&\n> -\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n> +\tgit cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author O Thor\" actual &&\n> +\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n> +\tgit --no-replace-objects show $HASH2 >actual &&\n> +\ttest_grep \"A U Thor\" actual\n>   '\n>   \n>   test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n> -\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n> +\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\"  actual &&\n> +\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n> +\ttest_grep \"A U Thor\" actual\n>   '\n>   \n>   test_expect_success 'test core.usereplacerefs config option' '\n>   \ttest_config core.usereplacerefs false &&\n> -\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tgit show $HASH2 | grep \"A U Thor\"\n> +\tgit cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"A U Thor\" actual\n>   '\n>   \n>   cat >tag.sig <<EOF\n> @@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n>   \tgit clone --no-hardlinks . clone_dir &&\n>   \t(\n>   \t\tcd clone_dir &&\n> -\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n> -\t\tgit show $HASH2 | grep \"A U Thor\" &&\n> +\t\tgit show HEAD~5 >actual &&\n> +\t\ttest_grep \"A U Thor\" actual &&\n> +\t\tgit show $HASH2 >actual &&\n> +\t\ttest_grep \"A U Thor\" actual &&\n>   \t\tgit cat-file commit $R &&\n>   \t\tgit repack -a -d &&\n>   \t\ttest_must_fail git cat-file commit $R &&\n>   \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n> -\t\tgit show HEAD~5 | grep \"O Thor\" &&\n> -\t\tgit show $HASH2 | grep \"O Thor\" &&\n> +\t\tgit show HEAD~5 >actual &&\n> +\t\ttest_grep \"O Thor\" actual &&\n> +\t\tgit show $HASH2 >actual &&\n> +\t\ttest_grep \"O Thor\" actual &&\n>   \t\tgit cat-file commit $R\n>   \t)\n>   '\n> @@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n>   \ttest_must_fail git replace --delete &&\n>   \ttest_must_fail git replace -l -d $HASH2 &&\n>   \tgit replace -d $HASH2 &&\n> -\tgit show $HASH2 | grep \"A U Thor\" &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"A U Thor\" actual &&\n>   \ttest -z \"$(git replace -l)\"\n>   '\n>   \n>   test_expect_success '\"git replace\" replacing' '\n>   \tgit replace $HASH2 $R &&\n> -\tgit show $HASH2 | grep \"O Thor\" &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n>   \ttest_must_fail git replace $HASH2 $R &&\n>   \tgit replace -f $HASH2 $R &&\n>   \ttest_must_fail git replace -f &&\n> @@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n>   \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n>   \tgit replace -d $SHORTHASH2 &&\n>   \tgit replace $SHORTHASH2 $R &&\n> -\tgit show $HASH2 | grep \"O Thor\" &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n>   \ttest_must_fail git replace $HASH2 $R &&\n>   \tgit replace -f $HASH2 $R &&\n>   \ttest_must_fail git replace --force &&\n> @@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n>   #\n>   test_expect_success 'create parallel branch without the bug' '\n>   \tgit replace -d $HASH2 &&\n> -\tgit show $HASH2 | grep \"A U Thor\" &&\n> +\tgit show $HASH2 >actual &&\n> +\ttest_grep \"A U Thor\" actual &&\n>   \tgit checkout $HASH1 &&\n>   \tgit cherry-pick $HASH2 &&\n> -\tgit show $HASH5 | git apply &&\n> +\tgit show $HASH5 >actual &&\n> +\tgit apply actual &&\n>   \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n>   \tPARA2=$(git rev-parse --verify HEAD) &&\n>   \tgit cherry-pick $HASH3 &&\n> @@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n>   \tgit checkout main &&\n>   \tcur=$(git rev-parse --verify HEAD) &&\n>   \ttest \"$cur\" = \"$HASH7\" &&\n> -\tgit log --pretty=oneline | grep $PARA2 &&\n> +\tgit log --pretty=oneline >actual &&\n> +\ttest_grep $PARA2 actual &&\n>   \tgit remote add cloned ./clone_dir\n>   '\n>   \n> @@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n>   \t(\n>   \t\tcd clone_dir &&\n>   \t\tgit checkout parallel &&\n> -\t\tgit log --pretty=oneline | grep $PARA2\n> +\t\tgit log --pretty=oneline >actual &&\n> +\t\ttest_grep $PARA2 actual\n>   \t)\n>   '\n>   \n>   test_expect_success 'push branch with replacement' '\n> -\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n> -\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> -\tgit cat-file commit $S | grep \"author O Thor\" &&\n> +\tgit cat-file commit $PARA3 >actual &&\n> +\ttest_grep \"author A U Thor\" actual &&\n> +\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> +\tgit cat-file commit $S >actual &&\n> +\ttest_grep \"author O Thor\" actual &&\n>   \tgit replace $PARA3 $S &&\n> -\tgit show $HASH6~2 | grep \"O Thor\" &&\n> -\tgit show $PARA3 | grep \"O Thor\" &&\n> +\tgit show $HASH6~2 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n> +\tgit show $PARA3 >actual &&\n> +\ttest_grep \"O Thor\" actual &&\n>   \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n>   \t(\n>   \t\tcd clone_dir &&\n>   \t\tgit checkout parallel2 &&\n> -\t\tgit log --pretty=oneline | grep $PARA3 &&\n> -\t\tgit show $PARA3 | grep \"A U Thor\"\n> +\t\tgit log --pretty=oneline >actual &&\n> +\t\ttest_grep $PARA3 actual &&\n> +\t\tgit show $PARA3 >actual &&\n> +\t\ttest_grep \"A U Thor\" actual\n>   \t)\n>   '\n>   \n> @@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n>   \t\tcd clone_dir &&\n>   \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n>   \t\tgit log --pretty=oneline parallel3 >output.txt &&\n> -\t\t! grep $PARA3 output.txt &&\n> +\t\ttest_grep ! $PARA3 output.txt &&\n>   \t\tgit show $PARA3 >para3.txt &&\n> -\t\tgrep \"A U Thor\" para3.txt &&\n> +\t\ttest_grep \"A U Thor\" para3.txt &&\n>   \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n>   \t\tgit log --pretty=oneline parallel3 >output.txt &&\n> -\t\tgrep $PARA3 output.txt &&\n> +\t\ttest_grep $PARA3 output.txt &&\n>   \t\tgit show $PARA3 >para3.txt &&\n> -\t\tgrep \"O Thor\" para3.txt\n> +\t\ttest_grep \"O Thor\" para3.txt\n>   \t)\n>   '\n>   \n> @@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n>   '\n>   \n>   test_expect_success 'index-pack and replacements' '\n> -\tgit --no-replace-objects rev-list --objects HEAD |\n> -\tgit --no-replace-objects pack-objects test- &&\n> +\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n> +\tgit --no-replace-objects pack-objects test- <actual &&\n>   \tgit index-pack test-*.pack\n>   '\n>   \n> @@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n>   '\n>   \n>   test_expect_success 'git cat-file --batch works on replace objects' '\n> -\tgit replace | grep $PARA3 &&\n> +\tgit replace >actual &&\n> +\ttest_grep $PARA3 actual &&\n>   \techo $PARA3 | git cat-file --batch\n>   '\n>   \n> @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n>   \t\techo \"$PARA3 -> $S\" &&\n>   \t\techo \"$MYTAG -> $HASH1\"\n>   \t} | sort >expected &&\n> -\tgit replace -l --format medium | sort >actual &&\n> +\tgit replace -l --format medium >output &&\n> +\tsort output >actual &&\n>   \ttest_cmp expected actual\n>   '\n>   \n> @@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n>   \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n>   \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n>   \t} | sort >expected &&\n> -\tgit replace --format=long | sort >actual &&\n> +\tgit replace --format=long >output &&\n> +\tsort output >actual &&\n>   \ttest_cmp expected actual\n>   '\n>   \n> @@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n>   test_expect_success '--edit with and without already replaced object' '\n>   \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n>   \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n> -\tgit replace -l | grep \"$PARA3\" &&\n> -\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n> +\tgit replace -l >actual &&\n> +\ttest_grep \"$PARA3\" actual &&\n> +\tgit cat-file commit \"$PARA3\" >actual &&\n> +\ttest_grep \"A fake Thor\" actual &&\n>   \tgit replace -d \"$PARA3\" &&\n>   \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n> -\tgit replace -l | grep \"$PARA3\" &&\n> -\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n> +\tgit replace -l >actual &&\n> +\ttest_grep \"$PARA3\" actual &&\n> +\tgit cat-file commit \"$PARA3\" >actual &&\n> +\ttest_grep \"A fake Thor\" actual\n>   '\n>   \n>   test_expect_success '--edit and change nothing or command failed' '\n> @@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n>   \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n>   \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n>   \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n> -\tgit replace -l | grep \"$PARA3\" &&\n> -\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n> +\tgit replace -l >actual &&\n> +\ttest_grep \"$PARA3\" actual &&\n> +\tgit cat-file commit \"$PARA3\" >actual &&\n> +\ttest_grep \"A fake Thor\" actual\n>   '\n>   \n>   test_expect_success 'replace ref cleanup' '\n> @@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n>   \tgit checkout main &&\n>   \tgit merge -s ours test_tag &&\n>   \tHASH10=$(git rev-parse --verify HEAD) &&\n> -\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n> +\tgit cat-file commit $HASH10 >actual &&\n> +\ttest_grep \"^mergetag object\" actual\n>   '\n>   \n>   test_expect_success GPG '--graft on a commit with a mergetag' '\n\n"},{"id":"505032","messageId":"20241014152411.11052-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"20241012062126.603967-1-chizobajames21@gmail.com","subject":"[Outreachy][PATCH v6] t6050: avoid pipes with upstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-14T15:24:11Z","receivedAt":"2024-10-14T15:24:59Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nChange in v6:\n- fixed a typographical error in the commit message\n\nRange-diff against v5:\n1:  b339b1f550 ! 1:  aad95a1b96 t6050: avoid pipes with upstream Git commands\n    @@ Commit message\n         failed \"grep\".\n     \n         Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n    -    Changes in v5:\n    -    - replace 'sort -o' which might not be supported by some platforms\n    -      to the more conventional output redirection, > .\n     \n      ## t/t6050-replace.sh ##\n     @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..37cb6547b6 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\"  actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"505033","messageId":"CACwP9aq-F=-y32h2-maiEtJ4rJgG0k5VdzVodnjFrCvKJLEuGQ@mail.gmail.com","threadId":"62285","inReplyTo":"879cac32-f59c-4adb-973e-4a8fc1770f8e@gmail.com","subject":"Re: [Outreachy][PATCH v5] t6050: avoid pipes with upstream Git commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-14T15:27:41Z","receivedAt":"2024-10-14T15:28:04Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"On Mon, 14 Oct 2024 at 15:00, Phillip Wood <phillip.wood123@gmail.com> wrote:\n>\n> Hi Chizoba\n>\n> On 12/10/2024 07:21, chizobajames21@gmail.com wrote:\n> > From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> >\n> > In pipes, the exit code of a chain of commands is determined by\n> > the final command. In order not to miss the exit code of a failed\n> > Git command, avoid pipes instead write output of Git commands\n> > into a file.\n> > For better debugging experience, instances of \"grep\" were changed\n> > to \"test_grep\". \"test_grep\" provides more context in case of a\n> > failed \"grep\".\n> >\n> > Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> > Changes in v5:\n> > - replace 'sort -o' which might not be supported by some platforms\n> >    to the more conventional output redirection, > .\n>\n> It's really helpful to list the changes like this, but please do so\n> below the \"---\" line so it does not become part of the commit message\nFixed.\n\n> when the patch is applied. The range-diff looks good, with a fixed up\n> commit message I think we can declare victory for this microproject.\n>\n> Best Wishes\n>\n> Phillip\n>\nThanks Philip\n\n> > ---\n> > Range-diff against v4:\n> > 1:  28cab4c752 ! 1:  b339b1f550 t6050: avoid pipes with upstream Git commands\n> >      @@ Commit message\n> >           failed \"grep\".\n> >\n> >           Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> >      -    Changes in v4:\n> >      -    - Correct the subject\n> >      -    - fixed some ommitted output option in sorts that where writing to\n> >      -      stdout\n> >      +    Changes in v5:\n> >      +    - replace 'sort -o' which might not be supported by some platforms\n> >      +      to the more conventional output redirection, > .\n> >\n> >        ## t/t6050-replace.sh ##\n> >       @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n> >      @@ t/t6050-replace.sh: test_expect_success 'test --format medium' '\n> >                       echo \"$MYTAG -> $HASH1\"\n> >               } | sort >expected &&\n> >       -       git replace -l --format medium | sort >actual &&\n> >      -+       git replace -l --format medium >actual &&\n> >      -+       sort actual -o actual &&\n> >      ++       git replace -l --format medium >output &&\n> >      ++       sort output >actual &&\n> >               test_cmp expected actual\n> >        '\n> >\n> >      @@ t/t6050-replace.sh: test_expect_success 'test --format long' '\n> >                       echo \"$MYTAG (tag) -> $HASH1 (commit)\"\n> >               } | sort >expected &&\n> >       -       git replace --format=long | sort >actual &&\n> >      -+       git replace --format=long >actual &&\n> >      -+       sort actual -o actual &&\n> >      ++       git replace --format=long >output &&\n> >      ++       sort output >actual &&\n> >               test_cmp expected actual\n> >        '\n> >\n> >\n> >   t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n> >   1 file changed, 86 insertions(+), 47 deletions(-)\n> >\n> > diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\n> > index d7702fc756..37cb6547b6 100755\n> > --- a/t/t6050-replace.sh\n> > +++ b/t/t6050-replace.sh\n> > @@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n> >   '\n> >\n> >   test_expect_success 'replace the author' '\n> > -     git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     R=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> > -     git cat-file commit $R | grep \"author O Thor\" &&\n> > +     git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     R=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> > +     git cat-file commit $R >actual &&\n> > +     test_grep \"author O Thor\" actual &&\n> >       git update-ref refs/replace/$HASH2 $R &&\n> > -     git show HEAD~5 | grep \"O Thor\" &&\n> > -     git show $HASH2 | grep \"O Thor\"\n> > +     git show HEAD~5 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"O Thor\" actual\n> >   '\n> >\n> >   test_expect_success 'test --no-replace-objects option' '\n> > -     git cat-file commit $HASH2 | grep \"author O Thor\" &&\n> > -     git --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     git show $HASH2 | grep \"O Thor\" &&\n> > -     git --no-replace-objects show $HASH2 | grep \"A U Thor\"\n> > +     git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author O Thor\" actual &&\n> > +     git --no-replace-objects cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> > +     git --no-replace-objects show $HASH2 >actual &&\n> > +     test_grep \"A U Thor\" actual\n> >   '\n> >\n> >   test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n> > -     GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n> > +     GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\"  actual &&\n> > +     GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n> > +     test_grep \"A U Thor\" actual\n> >   '\n> >\n> >   test_expect_success 'test core.usereplacerefs config option' '\n> >       test_config core.usereplacerefs false &&\n> > -     git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     git show $HASH2 | grep \"A U Thor\"\n> > +     git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"A U Thor\" actual\n> >   '\n> >\n> >   cat >tag.sig <<EOF\n> > @@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n> >       git clone --no-hardlinks . clone_dir &&\n> >       (\n> >               cd clone_dir &&\n> > -             git show HEAD~5 | grep \"A U Thor\" &&\n> > -             git show $HASH2 | grep \"A U Thor\" &&\n> > +             git show HEAD~5 >actual &&\n> > +             test_grep \"A U Thor\" actual &&\n> > +             git show $HASH2 >actual &&\n> > +             test_grep \"A U Thor\" actual &&\n> >               git cat-file commit $R &&\n> >               git repack -a -d &&\n> >               test_must_fail git cat-file commit $R &&\n> >               git fetch ../ \"refs/replace/*:refs/replace/*\" &&\n> > -             git show HEAD~5 | grep \"O Thor\" &&\n> > -             git show $HASH2 | grep \"O Thor\" &&\n> > +             git show HEAD~5 >actual &&\n> > +             test_grep \"O Thor\" actual &&\n> > +             git show $HASH2 >actual &&\n> > +             test_grep \"O Thor\" actual &&\n> >               git cat-file commit $R\n> >       )\n> >   '\n> > @@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n> >       test_must_fail git replace --delete &&\n> >       test_must_fail git replace -l -d $HASH2 &&\n> >       git replace -d $HASH2 &&\n> > -     git show $HASH2 | grep \"A U Thor\" &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"A U Thor\" actual &&\n> >       test -z \"$(git replace -l)\"\n> >   '\n> >\n> >   test_expect_success '\"git replace\" replacing' '\n> >       git replace $HASH2 $R &&\n> > -     git show $HASH2 | grep \"O Thor\" &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> >       test_must_fail git replace $HASH2 $R &&\n> >       git replace -f $HASH2 $R &&\n> >       test_must_fail git replace -f &&\n> > @@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n> >       SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n> >       git replace -d $SHORTHASH2 &&\n> >       git replace $SHORTHASH2 $R &&\n> > -     git show $HASH2 | grep \"O Thor\" &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> >       test_must_fail git replace $HASH2 $R &&\n> >       git replace -f $HASH2 $R &&\n> >       test_must_fail git replace --force &&\n> > @@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n> >   #\n> >   test_expect_success 'create parallel branch without the bug' '\n> >       git replace -d $HASH2 &&\n> > -     git show $HASH2 | grep \"A U Thor\" &&\n> > +     git show $HASH2 >actual &&\n> > +     test_grep \"A U Thor\" actual &&\n> >       git checkout $HASH1 &&\n> >       git cherry-pick $HASH2 &&\n> > -     git show $HASH5 | git apply &&\n> > +     git show $HASH5 >actual &&\n> > +     git apply actual &&\n> >       git commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n> >       PARA2=$(git rev-parse --verify HEAD) &&\n> >       git cherry-pick $HASH3 &&\n> > @@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n> >       git checkout main &&\n> >       cur=$(git rev-parse --verify HEAD) &&\n> >       test \"$cur\" = \"$HASH7\" &&\n> > -     git log --pretty=oneline | grep $PARA2 &&\n> > +     git log --pretty=oneline >actual &&\n> > +     test_grep $PARA2 actual &&\n> >       git remote add cloned ./clone_dir\n> >   '\n> >\n> > @@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n> >       (\n> >               cd clone_dir &&\n> >               git checkout parallel &&\n> > -             git log --pretty=oneline | grep $PARA2\n> > +             git log --pretty=oneline >actual &&\n> > +             test_grep $PARA2 actual\n> >       )\n> >   '\n> >\n> >   test_expect_success 'push branch with replacement' '\n> > -     git cat-file commit $PARA3 | grep \"author A U Thor\" &&\n> > -     S=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n> > -     git cat-file commit $S | grep \"author O Thor\" &&\n> > +     git cat-file commit $PARA3 >actual &&\n> > +     test_grep \"author A U Thor\" actual &&\n> > +     S=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n> > +     git cat-file commit $S >actual &&\n> > +     test_grep \"author O Thor\" actual &&\n> >       git replace $PARA3 $S &&\n> > -     git show $HASH6~2 | grep \"O Thor\" &&\n> > -     git show $PARA3 | grep \"O Thor\" &&\n> > +     git show $HASH6~2 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> > +     git show $PARA3 >actual &&\n> > +     test_grep \"O Thor\" actual &&\n> >       git push cloned $HASH6^:refs/heads/parallel2 &&\n> >       (\n> >               cd clone_dir &&\n> >               git checkout parallel2 &&\n> > -             git log --pretty=oneline | grep $PARA3 &&\n> > -             git show $PARA3 | grep \"A U Thor\"\n> > +             git log --pretty=oneline >actual &&\n> > +             test_grep $PARA3 actual &&\n> > +             git show $PARA3 >actual &&\n> > +             test_grep \"A U Thor\" actual\n> >       )\n> >   '\n> >\n> > @@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n> >               cd clone_dir &&\n> >               git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n> >               git log --pretty=oneline parallel3 >output.txt &&\n> > -             ! grep $PARA3 output.txt &&\n> > +             test_grep ! $PARA3 output.txt &&\n> >               git show $PARA3 >para3.txt &&\n> > -             grep \"A U Thor\" para3.txt &&\n> > +             test_grep \"A U Thor\" para3.txt &&\n> >               git fetch origin \"refs/replace/*:refs/replace/*\" &&\n> >               git log --pretty=oneline parallel3 >output.txt &&\n> > -             grep $PARA3 output.txt &&\n> > +             test_grep $PARA3 output.txt &&\n> >               git show $PARA3 >para3.txt &&\n> > -             grep \"O Thor\" para3.txt\n> > +             test_grep \"O Thor\" para3.txt\n> >       )\n> >   '\n> >\n> > @@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n> >   '\n> >\n> >   test_expect_success 'index-pack and replacements' '\n> > -     git --no-replace-objects rev-list --objects HEAD |\n> > -     git --no-replace-objects pack-objects test- &&\n> > +     git --no-replace-objects rev-list --objects HEAD >actual &&\n> > +     git --no-replace-objects pack-objects test- <actual &&\n> >       git index-pack test-*.pack\n> >   '\n> >\n> > @@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n> >   '\n> >\n> >   test_expect_success 'git cat-file --batch works on replace objects' '\n> > -     git replace | grep $PARA3 &&\n> > +     git replace >actual &&\n> > +     test_grep $PARA3 actual &&\n> >       echo $PARA3 | git cat-file --batch\n> >   '\n> >\n> > @@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n> >               echo \"$PARA3 -> $S\" &&\n> >               echo \"$MYTAG -> $HASH1\"\n> >       } | sort >expected &&\n> > -     git replace -l --format medium | sort >actual &&\n> > +     git replace -l --format medium >output &&\n> > +     sort output >actual &&\n> >       test_cmp expected actual\n> >   '\n> >\n> > @@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n> >               echo \"$PARA3 (commit) -> $S (commit)\" &&\n> >               echo \"$MYTAG (tag) -> $HASH1 (commit)\"\n> >       } | sort >expected &&\n> > -     git replace --format=long | sort >actual &&\n> > +     git replace --format=long >output &&\n> > +     sort output >actual &&\n> >       test_cmp expected actual\n> >   '\n> >\n> > @@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n> >   test_expect_success '--edit with and without already replaced object' '\n> >       test_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n> >       GIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n> > -     git replace -l | grep \"$PARA3\" &&\n> > -     git cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n> > +     git replace -l >actual &&\n> > +     test_grep \"$PARA3\" actual &&\n> > +     git cat-file commit \"$PARA3\" >actual &&\n> > +     test_grep \"A fake Thor\" actual &&\n> >       git replace -d \"$PARA3\" &&\n> >       GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n> > -     git replace -l | grep \"$PARA3\" &&\n> > -     git cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n> > +     git replace -l >actual &&\n> > +     test_grep \"$PARA3\" actual &&\n> > +     git cat-file commit \"$PARA3\" >actual &&\n> > +     test_grep \"A fake Thor\" actual\n> >   '\n> >\n> >   test_expect_success '--edit and change nothing or command failed' '\n> > @@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n> >       test_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n> >       test_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n> >       GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n> > -     git replace -l | grep \"$PARA3\" &&\n> > -     git cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n> > +     git replace -l >actual &&\n> > +     test_grep \"$PARA3\" actual &&\n> > +     git cat-file commit \"$PARA3\" >actual &&\n> > +     test_grep \"A fake Thor\" actual\n> >   '\n> >\n> >   test_expect_success 'replace ref cleanup' '\n> > @@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n> >       git checkout main &&\n> >       git merge -s ours test_tag &&\n> >       HASH10=$(git rev-parse --verify HEAD) &&\n> > -     git cat-file commit $HASH10 | grep \"^mergetag object\"\n> > +     git cat-file commit $HASH10 >actual &&\n> > +     test_grep \"^mergetag object\" actual\n> >   '\n> >\n> >   test_expect_success GPG '--graft on a commit with a mergetag' '\n>\n"},{"id":"505077","messageId":"Zw2T3PmdbgRGrIdF@nand.local","threadId":"62285","inReplyTo":"20241014152411.11052-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v6] t6050: avoid pipes with upstream Git commands","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-14T21:57:48Z","receivedAt":"2024-10-14T21:57:50Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Mon, Oct 14, 2024 at 04:24:11PM +0100, chizobajames21@gmail.com wrote:\n>  test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n> -\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> -\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n> +\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n> +\ttest_grep \"author A U Thor\"  actual &&\n\nNit: it looks like there is an extra space between the closing '\"' quote\ncharacter and the filename 'actual'.\n\n> @@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n>  '\n>\n>  test_expect_success 'index-pack and replacements' '\n> -\tgit --no-replace-objects rev-list --objects HEAD |\n> -\tgit --no-replace-objects pack-objects test- &&\n> +\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n> +\tgit --no-replace-objects pack-objects test- <actual &&\n>  \tgit index-pack test-*.pack\n>  '\n\nHmm. In other instances, actual seems like an OK name choice, but here I\nwonder if 'in' would be more appropriate, since we're feeding it as\ninput to another Git command.\n\nOther than those couple of comments, these all look pretty reasonable to\nme.\n\nThanks,\nTaylor\n"},{"id":"505137","messageId":"CACwP9aqecUKmN37JYW2qYRhe6nw-Owp5Cp-6Xjb1k7=_zaYmbQ@mail.gmail.com","threadId":"62285","inReplyTo":"Zw2T3PmdbgRGrIdF@nand.local","subject":"Re: [Outreachy][PATCH v6] t6050: avoid pipes with upstream Git commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-15T11:07:55Z","receivedAt":"2024-10-15T11:08:09Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"Hi Taylor\n\nOn Mon, 14 Oct 2024 at 22:57, Taylor Blau <me@ttaylorr.com> wrote:\n>\n> On Mon, Oct 14, 2024 at 04:24:11PM +0100, chizobajames21@gmail.com wrote:\n> >  test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n> > -     GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n> > -     GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n> > +     GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n> > +     test_grep \"author A U Thor\"  actual &&\n>\n> Nit: it looks like there is an extra space between the closing '\"' quote\n> character and the filename 'actual'.\n>\nThanks for spotting this out. I will fix this up in the next patch.\n> > @@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n> >  '\n> >\n> >  test_expect_success 'index-pack and replacements' '\n> > -     git --no-replace-objects rev-list --objects HEAD |\n> > -     git --no-replace-objects pack-objects test- &&\n> > +     git --no-replace-objects rev-list --objects HEAD >actual &&\n> > +     git --no-replace-objects pack-objects test- <actual &&\n> >       git index-pack test-*.pack\n> >  '\n>\n> Hmm. In other instances, actual seems like an OK name choice, but here I\n> wonder if 'in' would be more appropriate, since we're feeding it as\n> input to another Git command.\n>\nGiven that it's actually (puns intended) an output from the Git command in the\npreceding line, isn't a neutral name, like 'actual' a better choice than 'in'.\n> Other than those couple of comments, these all look pretty reasonable to\n> me.\n>\n> Thanks,\n> Taylor\nThanks for the comments.\nChizoba\n"},{"id":"505141","messageId":"20241015112645.415955-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"CACwP9aqecUKmN37JYW2qYRhe6nw-Owp5Cp-6Xjb1k7=_zaYmbQ@mail.gmail.com","subject":"[Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-15T11:26:45Z","receivedAt":"2024-10-15T11:27:00Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nWhat changed:\n- a typography error, excess whitespace\n\nRange-diff against v6:\n1:  aad95a1b96 ! 1:  14c677dd80 t6050: avoid pipes with upstream Git commands\n    @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n     -\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n     -\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n     +\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n    -+\ttest_grep \"author A U Thor\"  actual &&\n    ++\ttest_grep \"author A U Thor\" actual &&\n     +\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n     +\ttest_grep \"A U Thor\" actual\n      '\n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..deba3ca430 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"505795","messageId":"20241022012701.8959-1-chizobajames21@gmail.com","threadId":"62285","inReplyTo":"20241014152411.11052-1-chizobajames21@gmail.com","subject":"[Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commands","fromName":"","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-22T01:27:01Z","receivedAt":"2024-10-22T01:27:17Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"From: Chizoba ODINAKA <chizobajames21@gmail.com>\n\nIn pipes, the exit code of a chain of commands is determined by\nthe final command. In order not to miss the exit code of a failed\nGit command, avoid pipes instead write output of Git commands\ninto a file.\nFor better debugging experience, instances of \"grep\" were changed\nto \"test_grep\". \"test_grep\" provides more context in case of a\nfailed \"grep\".\n\nSigned-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n---\nWhat changed:\n- a typography error, excess whitespace\n\nRange-diff against v6:\n1:  aad95a1b96 ! 1:  14c677dd80 t6050: avoid pipes with upstream Git commands\n    @@ t/t6050-replace.sh: test_expect_success 'set up buggy branch' '\n     -\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n     -\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n     +\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n    -+\ttest_grep \"author A U Thor\"  actual &&\n    ++\ttest_grep \"author A U Thor\" actual &&\n     +\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n     +\ttest_grep \"A U Thor\" actual\n      '\n\n t/t6050-replace.sh | 133 +++++++++++++++++++++++++++++----------------\n 1 file changed, 86 insertions(+), 47 deletions(-)\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex d7702fc756..deba3ca430 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '\n '\n \n test_expect_success 'replace the author' '\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tR=$(git cat-file commit $HASH2 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $R | grep \"author O Thor\" &&\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tR=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $R >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit update-ref refs/replace/$HASH2 $R &&\n-\tgit show HEAD~5 | grep \"O Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\"\n+\tgit show HEAD~5 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual\n '\n \n test_expect_success 'test --no-replace-objects option' '\n-\tgit cat-file commit $HASH2 | grep \"author O Thor\" &&\n-\tgit --no-replace-objects cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n-\tgit --no-replace-objects show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n+\tgit --no-replace-objects cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit --no-replace-objects show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '\n-\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep \"A U Thor\"\n+\tGIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tGIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n test_expect_success 'test core.usereplacerefs config option' '\n \ttest_config core.usereplacerefs false &&\n-\tgit cat-file commit $HASH2 | grep \"author A U Thor\" &&\n-\tgit show $HASH2 | grep \"A U Thor\"\n+\tgit cat-file commit $HASH2 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual\n '\n \n cat >tag.sig <<EOF\n@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '\n \tgit clone --no-hardlinks . clone_dir &&\n \t(\n \t\tcd clone_dir &&\n-\t\tgit show HEAD~5 | grep \"A U Thor\" &&\n-\t\tgit show $HASH2 | grep \"A U Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"A U Thor\" actual &&\n \t\tgit cat-file commit $R &&\n \t\tgit repack -a -d &&\n \t\ttest_must_fail git cat-file commit $R &&\n \t\tgit fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-\t\tgit show HEAD~5 | grep \"O Thor\" &&\n-\t\tgit show $HASH2 | grep \"O Thor\" &&\n+\t\tgit show HEAD~5 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n+\t\tgit show $HASH2 >actual &&\n+\t\ttest_grep \"O Thor\" actual &&\n \t\tgit cat-file commit $R\n \t)\n '\n@@ -169,13 +185,15 @@ test_expect_success '\"git replace\" listing and deleting' '\n \ttest_must_fail git replace --delete &&\n \ttest_must_fail git replace -l -d $HASH2 &&\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \ttest -z \"$(git replace -l)\"\n '\n \n test_expect_success '\"git replace\" replacing' '\n \tgit replace $HASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace -f &&\n@@ -186,7 +204,8 @@ test_expect_success '\"git replace\" resolves sha1' '\n \tSHORTHASH2=$(git rev-parse --short=8 $HASH2) &&\n \tgit replace -d $SHORTHASH2 &&\n \tgit replace $SHORTHASH2 $R &&\n-\tgit show $HASH2 | grep \"O Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \ttest_must_fail git replace $HASH2 $R &&\n \tgit replace -f $HASH2 $R &&\n \ttest_must_fail git replace --force &&\n@@ -209,10 +228,12 @@ test_expect_success '\"git replace\" resolves sha1' '\n #\n test_expect_success 'create parallel branch without the bug' '\n \tgit replace -d $HASH2 &&\n-\tgit show $HASH2 | grep \"A U Thor\" &&\n+\tgit show $HASH2 >actual &&\n+\ttest_grep \"A U Thor\" actual &&\n \tgit checkout $HASH1 &&\n \tgit cherry-pick $HASH2 &&\n-\tgit show $HASH5 | git apply &&\n+\tgit show $HASH5 >actual &&\n+\tgit apply actual &&\n \tgit commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n \tPARA2=$(git rev-parse --verify HEAD) &&\n \tgit cherry-pick $HASH3 &&\n@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '\n \tgit checkout main &&\n \tcur=$(git rev-parse --verify HEAD) &&\n \ttest \"$cur\" = \"$HASH7\" &&\n-\tgit log --pretty=oneline | grep $PARA2 &&\n+\tgit log --pretty=oneline >actual &&\n+\ttest_grep $PARA2 actual &&\n \tgit remote add cloned ./clone_dir\n '\n \n@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel &&\n-\t\tgit log --pretty=oneline | grep $PARA2\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA2 actual\n \t)\n '\n \n test_expect_success 'push branch with replacement' '\n-\tgit cat-file commit $PARA3 | grep \"author A U Thor\" &&\n-\tS=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n-\tgit cat-file commit $S | grep \"author O Thor\" &&\n+\tgit cat-file commit $PARA3 >actual &&\n+\ttest_grep \"author A U Thor\" actual &&\n+\tS=$(sed -e \"s/A U/O/\" actual | git hash-object -t commit --stdin -w) &&\n+\tgit cat-file commit $S >actual &&\n+\ttest_grep \"author O Thor\" actual &&\n \tgit replace $PARA3 $S &&\n-\tgit show $HASH6~2 | grep \"O Thor\" &&\n-\tgit show $PARA3 | grep \"O Thor\" &&\n+\tgit show $HASH6~2 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n+\tgit show $PARA3 >actual &&\n+\ttest_grep \"O Thor\" actual &&\n \tgit push cloned $HASH6^:refs/heads/parallel2 &&\n \t(\n \t\tcd clone_dir &&\n \t\tgit checkout parallel2 &&\n-\t\tgit log --pretty=oneline | grep $PARA3 &&\n-\t\tgit show $PARA3 | grep \"A U Thor\"\n+\t\tgit log --pretty=oneline >actual &&\n+\t\ttest_grep $PARA3 actual &&\n+\t\tgit show $PARA3 >actual &&\n+\t\ttest_grep \"A U Thor\" actual\n \t)\n '\n \n@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '\n \t\tcd clone_dir &&\n \t\tgit fetch origin refs/heads/tofetch:refs/heads/parallel3 &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\t! grep $PARA3 output.txt &&\n+\t\ttest_grep ! $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"A U Thor\" para3.txt &&\n+\t\ttest_grep \"A U Thor\" para3.txt &&\n \t\tgit fetch origin \"refs/replace/*:refs/replace/*\" &&\n \t\tgit log --pretty=oneline parallel3 >output.txt &&\n-\t\tgrep $PARA3 output.txt &&\n+\t\ttest_grep $PARA3 output.txt &&\n \t\tgit show $PARA3 >para3.txt &&\n-\t\tgrep \"O Thor\" para3.txt\n+\t\ttest_grep \"O Thor\" para3.txt\n \t)\n '\n \n@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '\n '\n \n test_expect_success 'index-pack and replacements' '\n-\tgit --no-replace-objects rev-list --objects HEAD |\n-\tgit --no-replace-objects pack-objects test- &&\n+\tgit --no-replace-objects rev-list --objects HEAD >actual &&\n+\tgit --no-replace-objects pack-objects test- <actual &&\n \tgit index-pack test-*.pack\n '\n \n@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '\n '\n \n test_expect_success 'git cat-file --batch works on replace objects' '\n-\tgit replace | grep $PARA3 &&\n+\tgit replace >actual &&\n+\ttest_grep $PARA3 actual &&\n \techo $PARA3 | git cat-file --batch\n '\n \n@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '\n \t\techo \"$PARA3 -> $S\" &&\n \t\techo \"$MYTAG -> $HASH1\"\n \t} | sort >expected &&\n-\tgit replace -l --format medium | sort >actual &&\n+\tgit replace -l --format medium >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '\n \t\techo \"$PARA3 (commit) -> $S (commit)\" &&\n \t\techo \"$MYTAG (tag) -> $HASH1 (commit)\"\n \t} | sort >expected &&\n-\tgit replace --format=long | sort >actual &&\n+\tgit replace --format=long >output &&\n+\tsort output >actual &&\n \ttest_cmp expected actual\n '\n \n@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '\n test_expect_success '--edit with and without already replaced object' '\n \ttest_must_fail env GIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --force --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\" &&\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual &&\n \tgit replace -d \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success '--edit and change nothing or command failed' '\n@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '\n \ttest_must_fail env GIT_EDITOR=true git replace --edit \"$PARA3\" &&\n \ttest_must_fail env GIT_EDITOR=\"./failingfakeeditor\" git replace --edit \"$PARA3\" &&\n \tGIT_EDITOR=./fakeeditor git replace --edit \"$PARA3\" &&\n-\tgit replace -l | grep \"$PARA3\" &&\n-\tgit cat-file commit \"$PARA3\" | grep \"A fake Thor\"\n+\tgit replace -l >actual &&\n+\ttest_grep \"$PARA3\" actual &&\n+\tgit cat-file commit \"$PARA3\" >actual &&\n+\ttest_grep \"A fake Thor\" actual\n '\n \n test_expect_success 'replace ref cleanup' '\n@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '\n \tgit checkout main &&\n \tgit merge -s ours test_tag &&\n \tHASH10=$(git rev-parse --verify HEAD) &&\n-\tgit cat-file commit $HASH10 | grep \"^mergetag object\"\n+\tgit cat-file commit $HASH10 >actual &&\n+\ttest_grep \"^mergetag object\" actual\n '\n \n test_expect_success GPG '--graft on a commit with a mergetag' '\n-- \n2.34.1\n\n"},{"id":"505796","messageId":"CACwP9apQ0mwpw13K5N8PVMcBZrSrYWH4ry_abH8RPrNo8A3WbA@mail.gmail.com","threadId":"62285","inReplyTo":"20241022012701.8959-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commands","fromName":"Chizoba ODINAKA","fromEmail":"chizobajames21@gmail.com","sentAt":"2024-10-22T01:37:02Z","receivedAt":"2024-10-22T01:37:15Z","isPatch":true,"sender":{"key":"chizobajames21@gmail.com","avatar":"https://avatars.githubusercontent.com/u/96120948?v=4"},"body":"Hi\n\nOn Tue, 22 Oct 2024 at 02:27, <chizobajames21@gmail.com> wrote:\n>\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n>\n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n>\n> Signed-off-by: Chizoba ODINAKA <chizobajames21@gmail.com>\n> ---\n> What changed:\n> - a typography error, excess whitespace\n>\nThis patch version has implemented all recommended changes.\nThanks\nChizoba\n"},{"id":"505801","messageId":"Zxcx6otjnmn6LLJ4@pks.im","threadId":"62285","inReplyTo":"20241022012701.8959-1-chizobajames21@gmail.com","subject":"Re: [Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commands","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-10-22T05:02:41Z","receivedAt":"2024-10-22T05:02:49Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Oct 22, 2024 at 02:27:01AM +0100, chizobajames21@gmail.com wrote:\n> From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> \n> In pipes, the exit code of a chain of commands is determined by\n> the final command. In order not to miss the exit code of a failed\n> Git command, avoid pipes instead write output of Git commands\n> into a file.\n> For better debugging experience, instances of \"grep\" were changed\n> to \"test_grep\". \"test_grep\" provides more context in case of a\n> failed \"grep\".\n\nThanks, this version looks good to me!\n\nPatrick\n"},{"id":"505845","messageId":"ZxfXVvPtpT7SN10s@nand.local","threadId":"62285","inReplyTo":"Zxcx6otjnmn6LLJ4@pks.im","subject":"Re: [Outreachy][PATCH v7] t6050: avoid pipes with upstream Git commands","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2024-10-22T16:48:22Z","receivedAt":"2024-10-22T16:48:24Z","isPatch":true,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Tue, Oct 22, 2024 at 07:02:41AM +0200, Patrick Steinhardt wrote:\n> On Tue, Oct 22, 2024 at 02:27:01AM +0100, chizobajames21@gmail.com wrote:\n> > From: Chizoba ODINAKA <chizobajames21@gmail.com>\n> >\n> > In pipes, the exit code of a chain of commands is determined by\n> > the final command. In order not to miss the exit code of a failed\n> > Git command, avoid pipes instead write output of Git commands\n> > into a file.\n> > For better debugging experience, instances of \"grep\" were changed\n> > to \"test_grep\". \"test_grep\" provides more context in case of a\n> > failed \"grep\".\n>\n> Thanks, this version looks good to me!\n\nThanks, both. Let's start merging this one down.\n\nThanks,\nTaylor\n"}]}