Skip to content

Commit

Permalink
Fix ldiff binary files comparison and output
Browse files Browse the repository at this point in the history
Before this change, the comparison was reversed and diff were not
detected.

This commit also change the output when a diff is detected to look
like the GNU diff output.

Also fix the support of all other format than :report, by quickly
halting the diff process if there is a binary diff.
  • Loading branch information
Annih committed Jan 28, 2025
1 parent f56ad20 commit 28de1fb
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 0 deletions.
Binary file added spec/fixtures/file1.bin
Binary file not shown.
Binary file added spec/fixtures/file2.bin
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/ldiff/output.diff.bin2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
1 change: 1 addition & 0 deletions spec/fixtures/ldiff/output.diff.bin2-c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
1 change: 1 addition & 0 deletions spec/fixtures/ldiff/output.diff.bin2-e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
1 change: 1 addition & 0 deletions spec/fixtures/ldiff/output.diff.bin2-f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
1 change: 1 addition & 0 deletions spec/fixtures/ldiff/output.diff.bin2-u
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
2 changes: 2 additions & 0 deletions spec/ldiff_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# standard:disable Style/HashSyntax
fixtures = [
{:name => "output.diff", :left => "aX", :right => "bXaX", :diff => 1},
{:name => "output.diff.bin1", :left => "file1.bin", :right => "file1.bin", :diff => 0},
{:name => "output.diff.bin2", :left => "file1.bin", :right => "file2.bin", :diff => 1},
{:name => "output.diff.chef", :left => "old-chef", :right => "new-chef", :diff => 1},
{:name => "output.diff.chef2", :left => "old-chef2", :right => "new-chef2", :diff => 1}
].product([nil, "-e", "-f", "-c", "-u"]).map { |(fixture, flag)|
Expand Down

0 comments on commit 28de1fb

Please sign in to comment.