Skip to content

Commit 50fb51e

Browse files
committed
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 <[email protected]>
1 parent 6468a4e commit 50fb51e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

t/t4055-diff-context.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ test_description='diff.context configuration'
88
. ./test-lib.sh
99

1010
test_expect_success 'setup' '
11-
cat >x <<-\EOF &&
11+
cat >template <<-\EOF &&
1212
firstline
1313
b
1414
c
1515
d
1616
e
1717
f
1818
preline
19+
TARGET
1920
postline
2021
i
2122
j
@@ -24,17 +25,15 @@ test_expect_success 'setup' '
2425
m
2526
n
2627
EOF
28+
sed "/TARGET/d" >x <template &&
2729
git update-index --add x &&
2830
git commit -m initial &&
2931
30-
git cat-file blob HEAD:x |
31-
sed "/preline/a\
32-
ADDED" >x &&
32+
sed "s/TARGET/ADDED/" >x <template &&
3333
git update-index --add x &&
3434
git commit -m next &&
3535
36-
git cat-file blob HEAD:x |
37-
sed s/ADDED/MODIFIED/ >x
36+
sed "s/TARGET/MODIFIED/" >x <template
3837
'
3938

4039
test_expect_success 'the default number of context lines is 3' '

0 commit comments

Comments
 (0)