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

[PATCH 2/2] t5333: fix missing terminator for sed(1) 's' command

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 7, 2025, 11:08 UTC
Message-ID
<20250707-b4-pks-t-perlless-fixes-v1-2-92b2de1c3dd0@pks.im>
In-Reply-To
<20250707-b4-pks-t-perlless-fixes-v1-0-92b2de1c3dd0@pks.im>

In 6aec8d38fdd (t: refactor tests depending on Perl to print data, 2025-04-03) we have changed some of the tests in t4150 to use sed(1) instead of Perl. One of the conversions is broken though:

    sed: -e expression #1, char 41: unterminated `s' command

Curiously enough, the test itself still passes. This is caused by a sequence of failures:

  1. The output of sed(1) is piped into git-update-ref(1), and because
     sed(1) is the upstream command we don't notice that it fails.
  2. git-update-ref(1) does not receive any input and thus won't create
     any references.
  3. We then repack the repository with the configured pseudo merges
     pattern, but as we didn't create any references the pattern doesn't
     match anything.
  4. We use `test_pseudo_merges()` to compute the list of pseudo-merges
     and write it into a file. This file is empty as there are none.
  5. The loop over the pseudo-merges becomes a no-op.
  6. The final test succeeds as well because the number of lines in an
     empty file is obviously the same as the number of unique lines,
     namely zero.

Fix the issue by adding the terminating '|' to the sed(1) command. Furthermore, make the test a tiny bit more robust by not using it as part of a pipe.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t5333-pseudo-merge-bitmaps.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t5333-pseudo-merge-bitmaps.sh b/t/t5333-pseudo-merge-bitmaps.sh
index ba5ae6a00c9..1f7a5d82ee4 100755
--- a/t/t5333-pseudo-merge-bitmaps.sh
+++ b/t/t5333-pseudo-merge-bitmaps.sh
@@ -234,8 +234,8 @@ test_expect_success 'pseudo-merge pattern with capture groups' '
 			test_commit_bulk 16 &&
 
 			git rev-list HEAD~16.. >in &&
-			sed "s|\(.*\)|create refs/remotes/$r/tags/\1 \1" in |
-			git update-ref --stdin || return 1
+			sed "s|\(.*\)|create refs/remotes/$r/tags/\1 \1|" in >refs &&
+			git update-ref --stdin <refs || return 1
 		done &&
 
 		git \
-- 
2.50.0.195.g74e6fc65d0.dirty
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 3 of 5 in “t: fixes for Perl-less tests”
  1. 0/2 t: fixes for Perl-less testsPatrick Steinhardt, Jul 7, 2025
  2. 1/2 t4150: fix warning printed by awk due to escaped '\@'Patrick Steinhardt, Jul 7, 2025
  3. 2/2 t5333: fix missing terminator for sed(1) 's' commandPatrick Steinhardt, Jul 7, 2025
  4. Junio C HamanoJul 7, 2025
  5. Patrick SteinhardtJul 8, 2025

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.