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>

Junio C Hamano committed Oct 2, 2012 at 11:50 UTC 50fb51e7e81748182a770d3943ec5730357b27e7
1 file changed +5 -6
t/t4055-diff-context.sh
+5 -6
@@ -8,7 +8,7 @@ test_description='diff.context configuration'
8 . ./test-lib.sh
9
10 test_expect_success 'setup' '
11 - cat >x <<-\EOF &&
11 + cat >template <<-\EOF &&
12 firstline
13 b
14 c
@@ -16,6 +16,7 @@ test_expect_success 'setup' '
16 e
17 f
18 preline
19 + TARGET
20 postline
21 i
22 j
@@ -24,17 +25,15 @@ test_expect_success 'setup' '
25 m
26 n
27 EOF
28 + sed "/TARGET/d" >x <template &&
29 git update-index --add x &&
30 git commit -m initial &&
31
30 - git cat-file blob HEAD:x |
31 - sed "/preline/a\
32 - ADDED" >x &&
32 + sed "s/TARGET/ADDED/" >x <template &&
33 git update-index --add x &&
34 git commit -m next &&
35
36 - git cat-file blob HEAD:x |
37 - sed s/ADDED/MODIFIED/ >x
36 + sed "s/TARGET/MODIFIED/" >x <template
37 '
38
39 test_expect_success 'the default number of context lines is 3' '