Closed endruz closed 1 year ago
π AFAIK that does not seem like a valid unified diff. This project aims to support unified diffs including the super set from git diff.
You can read more about it here https://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html and here https://git-scm.com/docs/diff-format
In my understanding it seems like you are missing the ---
and +++
on the binary files.
Can you explain how you got that diff?
maybe i modifid the diff result and made it wiredπ i will show you a true example:
$ diff -ur a b
diff -ur a/htest.html b/htest.html
--- a/htest.html 2023-01-10 09:43:04.284427636 +0800
+++ b/htest.html 2023-01-10 09:43:10.308388990 +0800
@@ -1 +1 @@
-<a>test</a>
+<a>new test</a>
Binary files a/image.gif and b/image.gif differ
diff -ur a/test.json b/test.json
--- a/test.json 2023-01-10 09:43:07.832404870 +0800
+++ b/test.json 2023-01-10 09:43:12.708373605 +0800
@@ -1 +1 @@
-{"list": [1, 2]}
+{"list": [1, 2, 3]}
$ tree .
.
βββ a
βΒ Β βββ htest.html
βΒ Β βββ image.gif
βΒ Β βββ test.json
βββ b
βββ htest.html
βββ image.gif
βββ test.json
2 directories, 6 files
$ cat a/htest.html
<a>test</a>
$ cat b/htest.html
<a>new test</a>
$ cat a/test.json
{"list": [1, 2]}
$ cat b/test.json
{"list": [1, 2, 3]}
In my understanding it seems like you are missing the
---
and+++
on the binary files.
if i use diff -ur
, there doesn't seem to be the ---
and +++
on the binary files. π€
Can you run diff -ur a b > /tmp/test.diff
and then cat /tmp/test.diff
?
okay, it looks like this:
$ diff -ur a b > /tmp/test.diff
$ cat /tmp/test.diff
diff -ur a/htest.html b/htest.html
--- a/htest.html 2023-01-10 09:43:04.284427636 +0800
+++ b/htest.html 2023-01-10 09:43:10.308388990 +0800
@@ -1 +1 @@
-<a>test</a>
+<a>new test</a>
Binary files a/image.gif and b/image.gif differ
diff -ur a/test.json b/test.json
--- a/test.json 2023-01-10 09:43:07.832404870 +0800
+++ b/test.json 2023-01-10 09:43:12.708373605 +0800
@@ -1 +1 @@
-{"list": [1, 2]}
+{"list": [1, 2, 3]}
TBH this really seems like an invalid unified diff, but since it seemed easy to to cover I added support.
Hopefully this will not introduce any other problems.
in this case, we can find that the diff-content of
test.json
is displayed inimage.gif
part.binary file diff has displyed diff-content of previous file, like https://github.com/rtfpessoa/diff2html/issues/119 and https://github.com/rtfpessoa/diff2html/issues/233.
it is a pity that these two issues have no follow-up content π so I decided to describe it again