| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Test interdiff with patch2 having headers between +++ and @@ |
| 4 |
# This tests that interdiff can handle extra headers (like "index") between |
| 5 |
# the +++ line and @@ line in patch2, without incorrectly reporting it as empty |
| 6 |
|
| 7 |
. ${top_srcdir-.}/tests/common.sh |
| 8 |
|
| 9 |
# Create first patch (simple unified diff) |
| 10 |
cat << EOF > patch1 |
| 11 |
--- a/file.txt |
| 12 |
+++ b/file.txt |
| 13 |
@@ -1,3 +1,3 @@ |
| 14 |
line one |
| 15 |
-line two |
| 16 |
+line TWO |
| 17 |
line three |
| 18 |
EOF |
| 19 |
|
| 20 |
# Create second patch (git-style with index line between +++ and @@) |
| 21 |
cat << EOF > patch2 |
| 22 |
--- a/file.txt |
| 23 |
+++ b/file.txt |
| 24 |
index abc123..def456 100644 |
| 25 |
@@ -1,3 +1,3 @@ |
| 26 |
line one |
| 27 |
-line two |
| 28 |
+line 2 |
| 29 |
line three |
| 30 |
EOF |
| 31 |
|
| 32 |
# Expected interdiff output |
| 33 |
# This shows the difference between changing "two" to "TWO" vs "2" |
| 34 |
cat << EOF > expected |
| 35 |
diff -u b/file.txt b/file.txt |
| 36 |
--- b/file.txt |
| 37 |
+++ b/file.txt |
| 38 |
@@ -1,3 +1,3 @@ |
| 39 |
line one |
| 40 |
-line TWO |
| 41 |
+line 2 |
| 42 |
line three |
| 43 |
EOF |
| 44 |
|
| 45 |
# Run interdiff - should succeed without errors |
| 46 |
${INTERDIFF} patch1 patch2 2>errors >actual || exit 1 |
| 47 |
|
| 48 |
# Should not have any errors (especially not "patch2 is empty" or similar) |
| 49 |
[ -s errors ] && exit 1 |
| 50 |
|
| 51 |
# Compare the actual output with expected |
| 52 |
diff -u expected actual || exit 1 |
| 53 |
|
| 54 |
exit 0 |