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

Re: t4055 failure: see error

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 2, 2012, 19:09 UTC
Message-ID
<7vpq507ksy.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vy5jo7l7r.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Brian Charles Gernhardt <gernhard@cs.rochester.edu> writes:
>
>> Another problem caused by BSD v GNU sed, I think.
>>
>> 	git cat-file blob HEAD:x |
>> 	sed "/preline/a\
>> 	ADDED" >x &&
>
> Actually, I think what is happening is that inside "", the backslash
> at the end of line is eaten by the shell together with that end of
> line, so it is not BSD vs GNU, but it simply is that my quoting was
> wrong.
>
> This (disregarding the previous "TARGET" patch) may be a smaller fix.

I'll find a brown paper bag big enough to hide in. Please disregard it.

-- >8 --
Subject: [PATCH] t4055: avoid use of sed 'a' command

The 'a', 'i' and 'c' commands take a literal text to be added followed by backslash, but then in the source we cannot indent the literal text which makes it ugly.

We need to also remember to double the backslash inside double quotes.

Avoid these issues altogether by having an extra line in a template file and generate test vectors by deleting the line or replacing the line and not using the 'a' command.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4055-diff-context.sh | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/t/t4055-diff-context.sh b/t/t4055-diff-context.sh
index 3527686..97172b4 100755
--- a/t/t4055-diff-context.sh
+++ b/t/t4055-diff-context.sh
@@ -8,7 +8,7 @@ test_description='diff.context configuration'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-	cat >x <<-\EOF &&
+	cat >template <<-\EOF &&
 	firstline
 	b
 	c
@@ -16,6 +16,7 @@ test_expect_success 'setup' '
 	e
 	f
 	preline
+	TARGET
 	postline
 	i
 	j
@@ -24,17 +25,15 @@ test_expect_success 'setup' '
 	m
 	n
 	EOF
+	sed "/TARGET/d" >x <template &&
 	git update-index --add x &&
 	git commit -m initial &&
 
-	git cat-file blob HEAD:x |
-	sed "/preline/a\
-	ADDED" >x &&
+	sed "s/TARGET/ADDED/" >x <template &&
 	git update-index --add x &&
 	git commit -m next &&
 
-	git cat-file blob HEAD:x |
-	sed s/ADDED/MODIFIED/ >x
+	sed "s/TARGET/MODIFIED/" >x <template
 '
 
 test_expect_success 'the default number of context lines is 3' '
-- 
1.8.0.rc0.45.g7ce8dc5
Previous: Junio C HamanoNext: Brian Charles Gernhardt
Message 5 of 7 in “t4055 failure: see error”
  1. Brian Charles GernhardtOct 2, 2012
  2. Junio C HamanoOct 2, 2012
  3. Junio C HamanoOct 2, 2012
  4. Junio C HamanoOct 2, 2012
  5. Junio C HamanoOct 2, 2012
  6. Brian Charles GernhardtOct 7, 2012
  7. Junio C HamanoOct 7, 2012

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.