git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] t9832,t2200: avoid using pipes in git commands

From
Amanda Shafack via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 17, 2020, 16:02 UTC
Message-ID
<fc2da014a62c387009e2175435286afef64d6598.1602950552.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.885.git.git.1602950552.gitgitgadget@gmail.com>
From: Amanda Shafack <shafack.likhene@gmail.com>

When the upstream of a pipe throws an error, the downstream still executes normally. This happens because the exit code of the upstream in a pipe is ignored. This behavior can make debugging very hard incase a test fails. Also, pipes are prone to deadlocks. If the upstream gets full, the commands downstream will never start.

Write out the output of the git command to a file, so as to test the exit codes of both commands.

Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) noticed that the exit code of upstream in the pipe is ignored, thus using pipes should be avoided.

Signed-off-by: Amanda Shafack <shafack.likhene@gmail.com>
---
 t/t2200-add-update.sh | 5 ++++-
 t/t9832-unshelve.sh   | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index f764b7e3f5..2d850bb372 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -179,7 +179,10 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 test_expect_success '"add -u non-existent" should fail' '
 	test_must_fail git add -u non-existent &&
-	! (git ls-files | grep "non-existent")
+	! (
+		git ls-files >actual &&
+		grep "non-existent" actual
+	)
 '
 
 test_done
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index 7194fb2855..6b3cb0414a 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -68,7 +68,8 @@ EOF
 		cd "$git" &&
 		change=$(last_shelved_change) &&
 		git p4 unshelve $change &&
-		git show refs/remotes/p4-unshelved/$change | grep -q "Further description" &&
+		git show refs/remotes/p4-unshelved/$change >actual &&
+		grep -q "Further description" actual &&
 		git cherry-pick refs/remotes/p4-unshelved/$change &&
 		test_path_is_file file2 &&
 		test_cmp file1 "$cli"/file1 &&
-- 
gitgitgadget
Previous: Amanda ShafackNext: Eric Sunshine
Message 5 of 14 in “t9832,t2200: avoid using pipes in git related commands”
  1. 0/2 [Outreachy][Patch v1] t9832,t2200: avoid using pipes in git related commandsAmanda Shafack via GitGitGadget, Oct 17, 2020
  2. 2/2 t2200: modify code syntaxAmanda Shafack via GitGitGadget, Oct 17, 2020
  3. Eric SunshineOct 18, 2020
  4. Amanda ShafackOct 18, 2020
  5. 1/2 t9832,t2200: avoid using pipes in git commandsAmanda Shafack via GitGitGadget, Oct 17, 2020
  6. Eric SunshineOct 18, 2020
  7. Amanda ShafackOct 18, 2020
  8. t9832,t2200: avoid using pipes in git commandsAmanda Shafack via GitGitGadget, Oct 18, 2020
  9. Eric SunshineOct 18, 2020
  10. Junio C HamanoOct 18, 2020
  11. Amanda ShafackOct 18, 2020
  12. Amanda ShafackOct 18, 2020
  13. t2200,t9832: avoid using 'git' upstream in a pipeAmanda Shafack via GitGitGadget, Oct 18, 2020
  14. Junio C HamanoOct 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.