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

[PATCH v2 2/2] t6300: check for cat-file exit status code

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Aug 18, 2021, 05:19 UTC
Message-ID
<68ee769121195eb61bb51fd6a27d22a8dddb13b6.1629263759.git.congdanhqx@gmail.com>
In-Reply-To
<cover.1629263759.git.congdanhqx@gmail.com>

In test_atom(), we're piping the output of cat-file to tail(1), thus, losing its exit status.

Let's use a temporary file to preserve git exit status code.
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 t/t6300-for-each-ref.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 93126341b3..cc0f5b6627 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -66,7 +66,9 @@ test_atom() {
 			case $type in
 			tag)
 				# We cannot use $3 as it expects sanitize_pgp to run
-				expect=$(git cat-file tag $ref | tail -n +6 | wc -c) ;;
+				git cat-file tag $ref >out &&
+				expect=$(tail -n +6 <out | wc -c) &&
+				rm -f out ;;
 			tree | blob)
 				expect="" ;;
 			commit)
-- 
2.33.0.rc1
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 11 in “t6300: don't run cat-file on non-existent object”
  1. t6300: don't run cat-file on non-existent objectĐoàn Trần Công Danh, Aug 17, 2021
  2. Johannes SchindelinAug 17, 2021
  3. 0/2 t6300: clear warning when running without gpgĐoàn Trần Công Danh, Aug 18, 2021
  4. 1/2 t6300: don't run cat-file on non-existent objectĐoàn Trần Công Danh, Aug 18, 2021
  5. Junio C HamanoAug 19, 2021
  6. 2/2 t6300: check for cat-file exit status codeĐoàn Trần Công Danh, Aug 18, 2021
  7. Junio C HamanoAug 19, 2021
  8. Johannes SchindelinAug 18, 2021
  9. 0/2 t6300: clear warning when running without gpgĐoàn Trần Công Danh, Aug 21, 2021
  10. 1/2 t6300: don't run cat-file on non-existent objectĐoàn Trần Công Danh, Aug 21, 2021
  11. 2/2 t6300: check for cat-file exit status codeĐoàn Trần Công Danh, Aug 21, 2021

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.