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

[PATCH 1/3] test_ref_missing(): improve error message

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 27, 2026, 10:57 UTC
Message-ID
<e246ee6f3b11c231580752b6c94a57f31f449955.1793098652.git.phillip.wood@dunelm.org.uk>
In-Reply-To
<cover.1793098652.git.phillip.wood@dunelm.org.uk>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

If the ref being checked exists, then test_ref_missing() does not print the name of the ref in the error message. So, if there is more than one call to test_ref_missing() in a test, it is hard to understand which one failed by looking at the test output. Fix that by printing the name of the ref that erroneously exists.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 t/test-lib-functions.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 09a41d51adc..b56b4f0a6c8 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -292,18 +292,20 @@ test_ref_exists () {
 # a reference. This is preferable to `! test_ref_exists` as this function is
 # able to distinguish actually-missing references from other, generic errors.
 test_ref_missing () {
+	local refname
+	eval refname="\$$#"
 	test_ref_exists "$@"
 	case "$?" in
 	2)
 		# This is the good case.
 		return 0
 		;;
 	0)
-		echo >&4 "test_ref_missing: reference exists"
+		echo >&4 "test_ref_missing: '$refname' exists"
 		return 1
 		;;
 	*)
-		echo >&4 "test_ref_missing: generic error"
+		echo >&4 "test_ref_missing: generic error while checking '$refname'"
 		return 1
 		;;
 	esac
-- 
2.56.0.336.g97505d19352
Previous: Phillip WoodNext: Junio C Hamano
Message 2 of 7 in “sequencer: fix cleanup of REBASE_HEAD and AUTO_MERGE”
  1. 0/3 sequencer: fix cleanup of REBASE_HEAD and AUTO_MERGEPhillip Wood, Oct 27, 2026
  2. 1/3 test_ref_missing(): improve error messagePhillip Wood, Oct 27, 2026
  3. Junio C HamanoOct 27, 2026
  4. 2/3 sequencer: remove REBASE_HEAD at the end of a rebasePhillip Wood, Oct 27, 2026
  5. Junio C HamanoOct 27, 2026
  6. 3/3 sequencer: remove AUTO_MERGE at the end of a rebasePhillip Wood, Oct 27, 2026
  7. Junio C HamanoOct 27, 2026

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.