| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# This is a lsdiff(1) testcase for --lines option. |
| 4 |
# Test: Select files containing hunks that touch specific line numbers |
| 5 |
|
| 6 |
. ${top_srcdir-.}/tests/common.sh |
| 7 |
|
| 8 |
cat << EOF > diff |
| 9 |
--- file1 |
| 10 |
+++ file1 |
| 11 |
@@ -1 +1,2 @@ |
| 12 |
-A |
| 13 |
+a |
| 14 |
+b |
| 15 |
@@ -10 +11,2 @@ |
| 16 |
-C |
| 17 |
+c |
| 18 |
+d |
| 19 |
--- file2 |
| 20 |
+++ file2 |
| 21 |
@@ -5 +5,2 @@ |
| 22 |
-E |
| 23 |
+e |
| 24 |
+f |
| 25 |
@@ -20 +21,2 @@ |
| 26 |
-G |
| 27 |
+g |
| 28 |
+h |
| 29 |
--- file3 |
| 30 |
+++ file3 |
| 31 |
@@ -15 +15,2 @@ |
| 32 |
-I |
| 33 |
+i |
| 34 |
+j |
| 35 |
EOF |
| 36 |
|
| 37 |
# Test --lines 1 (files with hunks touching line 1) |
| 38 |
${LSDIFF} --lines 1 diff 2>errors >lines1 || exit 1 |
| 39 |
[ -s errors ] && exit 1 |
| 40 |
|
| 41 |
cat << EOF | cmp - lines1 || exit 1 |
| 42 |
file1 |
| 43 |
EOF |
| 44 |
|
| 45 |
# Test --lines 5 (files with hunks touching line 5) |
| 46 |
${LSDIFF} --lines 5 diff 2>errors >lines5 || exit 1 |
| 47 |
[ -s errors ] && exit 1 |
| 48 |
|
| 49 |
cat << EOF | cmp - lines5 || exit 1 |
| 50 |
file2 |
| 51 |
EOF |
| 52 |
|
| 53 |
# Test --lines 10-15 (range: files with hunks touching lines 10-15) |
| 54 |
${LSDIFF} --lines 10-15 diff 2>errors >lines10-15 || exit 1 |
| 55 |
[ -s errors ] && exit 1 |
| 56 |
|
| 57 |
cat << EOF | cmp - lines10-15 || exit 1 |
| 58 |
file1 |
| 59 |
file3 |
| 60 |
EOF |
| 61 |
|
| 62 |
# Test --lines 100 (line that doesn't exist - should be empty) |
| 63 |
${LSDIFF} --lines 100 diff 2>errors >lines100 || exit 1 |
| 64 |
[ -s errors ] && exit 1 |
| 65 |
[ -s lines100 ] && exit 1 # Should be empty |
| 66 |
exit 0 |