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>
This commit is contained in:
Junio C Hamano 2012-10-02 11:50:16 -07:00
parent 6468a4e548
commit 50fb51e7e8

View file

@ -8,7 +8,7 @@ test_description='diff.context configuration'
. ./test-lib.sh . ./test-lib.sh
test_expect_success 'setup' ' test_expect_success 'setup' '
cat >x <<-\EOF && cat >template <<-\EOF &&
firstline firstline
b b
c c
@ -16,6 +16,7 @@ test_expect_success 'setup' '
e e
f f
preline preline
TARGET
postline postline
i i
j j
@ -24,17 +25,15 @@ test_expect_success 'setup' '
m m
n n
EOF EOF
sed "/TARGET/d" >x <template &&
git update-index --add x && git update-index --add x &&
git commit -m initial && git commit -m initial &&
git cat-file blob HEAD:x | sed "s/TARGET/ADDED/" >x <template &&
sed "/preline/a\
ADDED" >x &&
git update-index --add x && git update-index --add x &&
git commit -m next && git commit -m next &&
git cat-file blob HEAD:x | sed "s/TARGET/MODIFIED/" >x <template
sed s/ADDED/MODIFIED/ >x
' '
test_expect_success 'the default number of context lines is 3' ' test_expect_success 'the default number of context lines is 3' '