| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Test for GitHub Issue #57: Binary files not supported |
| 4 |
# This test ensures that binary file diffs are handled correctly |
| 5 |
|
| 6 |
. ${top_srcdir-.}/tests/common.sh |
| 7 |
|
| 8 |
cat << EOF > git-binary.patch |
| 9 |
diff --git a/binary-file b/binary-file |
| 10 |
new file mode 100644 |
| 11 |
index 0000000..998a95d |
| 12 |
Binary files /dev/null and b/binary-file differ |
| 13 |
diff --git a/text-file.txt b/text-file.txt |
| 14 |
new file mode 100644 |
| 15 |
index 0000000..abcdefg |
| 16 |
--- /dev/null |
| 17 |
+++ b/text-file.txt |
| 18 |
@@ -0,0 +1,2 @@ |
| 19 |
+line 1 |
| 20 |
+line 2 |
| 21 |
EOF |
| 22 |
|
| 23 |
# Test that filterdiff includes binary files when they match |
| 24 |
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i binary-file git-binary.patch 2>errors >result || exit 1 |
| 25 |
[ -s errors ] && exit 1 |
| 26 |
|
| 27 |
cat << EOF | cmp - result || exit 1 |
| 28 |
diff --git a/binary-file b/binary-file |
| 29 |
new file mode 100644 |
| 30 |
index 0000000..998a95d |
| 31 |
Binary files /dev/null and b/binary-file differ |
| 32 |
EOF |
| 33 |
|
| 34 |
# Test that lsdiff shows binary files |
| 35 |
${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip git-binary.patch 2>errors2 >result2 || exit 1 |
| 36 |
[ -s errors2 ] && exit 1 |
| 37 |
|
| 38 |
cat << EOF | cmp - result2 || exit 1 |
| 39 |
binary-file |
| 40 |
text-file.txt |
| 41 |
EOF |
| 42 |
|
| 43 |
# Test excluding binary files |
| 44 |
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -x binary-file git-binary.patch 2>errors3 >result3 || exit 1 |
| 45 |
[ -s errors3 ] && exit 1 |
| 46 |
|
| 47 |
cat << EOF | cmp - result3 || exit 1 |
| 48 |
diff --git a/text-file.txt b/text-file.txt |
| 49 |
new file mode 100644 |
| 50 |
index 0000000..abcdefg |
| 51 |
--- /dev/null |
| 52 |
+++ b/text-file.txt |
| 53 |
@@ -0,0 +1,2 @@ |
| 54 |
+line 1 |
| 55 |
+line 2 |
| 56 |
EOF |
| 57 |
|
| 58 |
exit 0 |