Skip to content

Commit

Permalink
t4055: avoid use of sed 'a' command
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Oct 2, 2012
1 parent 6468a4e commit 50fb51e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions t/t4055-diff-context.sh
Expand Up @@ -8,14 +8,15 @@ test_description='diff.context configuration'
. ./test-lib.sh

test_expect_success 'setup' '
cat >x <<-\EOF &&
cat >template <<-\EOF &&
firstline
b
c
d
e
f
preline
TARGET
postline
i
j
Expand All @@ -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' '
Expand Down

0 comments on commit 50fb51e

Please sign in to comment.