Skip to content

Missing some changed lines when using UnifiedDiffReader.parseUnifiedDiff #83

@HuGanghui

Description

@HuGanghui

Describe the bug

Missing some changed lines when using UnifiedDiffReader.parseUnifiedDiff

To Reproduce
Steps to reproduce the behavior:

  1. Example data
  2. simple programm snippet
  3. See error

@Test
public void testParseIssue51() throws IOException {
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(
UnifiedDiffReaderTest.class.getResourceAsStream("problem_diff_issue51.diff"));
System.out.println(diff);
assertThat(diff.getFiles().size()).isEqualTo(2);
UnifiedDiffFile file1 = diff.getFiles().get(0);
assertThat(file1.getFromFile()).isEqualTo("f1");
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(1);
assertThat(diff.getTail()).isNull();
}

when debug this test, I found that patch of file f2 is empty, but in line 11 of problem_diff_issue51.diff is a changed line, right?

And the file1.getFromFile()).isEqualTo("f1"); should be old/f1 right? same as new/f1, old/f2, new/f2 in the diff file.

diff -U0 old/f2 new/f2
--- old/f2 2019-09-25 14:38:14.000000000 +0200
+++ new/f2 2019-09-25 14:38:32.000000000 +0200
@@ -1 +1 @@
-a\nc

image

Expected behavior
A clear and concise description of what you expected to happen.

System

  • Java version 1.8
  • Version
<groupId>io.github.java-diff-utils</groupId>
<artifactId>java-diff-utils</artifactId>
<version>4.5</version>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions