Impacted version
bundle exec ldiff --version
ldiff 1.5.1
Context
When performing a diff between a non-empty file and an empty file (could it be /dev/null), the ldiff output is very different than gnu diff and I would say ... wrong!
Repro
Let's take a file with 4 lines name four_lines:
cat -A four_lines
first$
second$
third$
last$
And now let's compare it with an empty file using unified format: bundle exec ldiff -u /dev/null four_lines
Current result
Here is what we get
--- /dev/null 2025-01-27 23:29:19.000000000 +0100
+++ four_lines 2025-01-28 08:43:54.000000000 +0100
@@ -1,3 +1,7 @@
\ No newline at end of file
+first
+second
+third
+fourth
Expected result
I would expect the same result as GNU diff:
--- /dev/null 2025-01-27 23:29:19.936649933 +0100
+++ four_lines 2025-01-28 08:43:54.620170046 +0100
@@ -0,0 +1,4 @@
+first
+second
+third
+fourth
The main issues I see ordered by ascending criticality:
- there should be no
No newline at end of file notice
- there seems to be an off by 1 thing in the range, but I think the patch is still valid (need to confirm)
- the number of "new lines" is definitely not
7!!!
More
The example I used here is 0 vs 4 lines in unified format, but:
- actually all format seems impacted
- any non-zero value would work 0 vs 1, 0 vs 2, 0 vs 1000
- it could also be inverested 1 vs 0, 2 vs 0 & 1000 vs 0 (the result is less scary though)
I'll submit soon a "fake PR" with tests to demonstrate some failures.
Impacted version
Context
When performing a diff between a non-empty file and an empty file (could it be
/dev/null), the ldiff output is very different than gnu diff and I would say ... wrong!Repro
Let's take a file with 4 lines name
four_lines:And now let's compare it with an empty file using unified format:
bundle exec ldiff -u /dev/null four_linesCurrent result
Here is what we get
Expected result
I would expect the same result as GNU diff:
The main issues I see ordered by ascending criticality:
No newline at end of filenotice7!!!More
The example I used here is 0 vs 4 lines in unified format, but:
I'll submit soon a "fake PR" with tests to demonstrate some failures.