|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# This is a test case for handling CRLF line endings in filenames |
| 4 | +# Test: Ensure lsdiff and filterdiff correctly handle CRLF in filenames and headers |
| 5 | + |
| 6 | +. ${top_srcdir-.}/tests/common.sh |
| 7 | + |
| 8 | +# Create some patches for adding and removing file cases |
| 9 | +cat <<"EOF" > create.patch |
| 10 | +diff --git a/test.txt b/test.txt |
| 11 | +new file mode 100644 |
| 12 | +index 0000000..257cc56 |
| 13 | +--- /dev/null |
| 14 | ++++ b/test.txt |
| 15 | +@@ -0,0 +1 @@ |
| 16 | ++foo |
| 17 | +diff --git a/a/b/c/test_indir.txt b/a/test_indir.txt |
| 18 | +new file mode 100644 |
| 19 | +index 0000000..257cc56 |
| 20 | +--- /dev/null |
| 21 | ++++ b/a/test_indir.txt |
| 22 | +@@ -0,0 +1 @@ |
| 23 | ++foo |
| 24 | +EOF |
| 25 | + |
| 26 | +cat <<"EOF" > remove.patch |
| 27 | +diff --git a/test.txt b/test.txt |
| 28 | +deleted file mode 100644 |
| 29 | +index 257cc56..0000000 |
| 30 | +--- a/test.txt |
| 31 | ++++ /dev/null |
| 32 | +@@ -1 +0,0 @@ |
| 33 | +-foo |
| 34 | +diff --git a/a/b/c/test_indir.txt b/a/b/c/test_indir.txt |
| 35 | +deleted file mode 100644 |
| 36 | +index 257cc56..0000000 |
| 37 | +--- a/a/b/c/test_indir.txt |
| 38 | ++++ /dev/null |
| 39 | +@@ -1 +0,0 @@ |
| 40 | +-foo |
| 41 | +EOF |
| 42 | + |
| 43 | +# Convert these patches to use CRLF line endings |
| 44 | +sed 's/$/\r/' create.patch > create.patch.crlf |
| 45 | +mv create.patch.crlf create.patch |
| 46 | + |
| 47 | +sed 's/$/\r/' remove.patch > remove.patch.crlf |
| 48 | +mv remove.patch.crlf remove.patch |
| 49 | + |
| 50 | +# Verify test.txt is in the lsdiff output |
| 51 | +${LSDIFF} create.patch > created_file 2>errors || exit 1 |
| 52 | +[ -s errors ] && exit 1 |
| 53 | +grep -F "test.txt" created_file || exit 1 |
| 54 | +grep -F "test_indir.txt" created_file || exit 1 |
| 55 | + |
| 56 | +${LSDIFF} remove.patch > removed_file 2>errors || exit 1 |
| 57 | +[ -s errors ] && exit 1 |
| 58 | +grep -F "test.txt" removed_file || exit 1 |
| 59 | +grep -F "test_indir.txt" removed_file || exit 1 |
| 60 | + |
| 61 | +# Verify the diff remains after filtering |
| 62 | +${FILTERDIFF} --include="*test*" create.patch > create_filter.patch 2>errors || exit 1 |
| 63 | +[ -s errors ] && exit 1 |
| 64 | +grep -F "test.txt" create_filter.patch || exit 1 |
| 65 | +grep -F "test_indir.txt" create_filter.patch || exit 1 |
| 66 | + |
| 67 | +${FILTERDIFF} --include="*test*" remove.patch > remove_filter.patch 2>errors || exit 1 |
| 68 | +[ -s errors ] && exit 1 |
| 69 | +grep -F "test.txt" remove_filter.patch || exit 1 |
| 70 | +grep -F "test_indir.txt" remove_filter.patch || exit 1 |
| 71 | + |
| 72 | +exit 0 |
0 commit comments