Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Diffs containing target code equal to source code are not represented as in Git #202

Copy link
Copy link
Open
@ArturMarcinkowski

Description

@ArturMarcinkowski
Issue body actions

Hi,
I recently encountered a bug where the way diffs are calculated differs from GitLab’s approach.

I've created an example to illustrate the issue. There are two lists to simulate lines before and after the changes.

There are two identical blocks of lines, so the changes can be interpreted in two different ways:

Git's approach: The first six lines are replaced with two new lines, while the last two lines remain unchanged.
DiffUtils' approach: The first two lines are replaced with two new lines, the next two lines remain unchanged, and the last four lines are removed.
While both approaches lead to the same final result, DiffUtils returns CHANGE, EQUAL, and DELETE blocks, whereas Git only uses CHANGE and EQUAL.

List<String> beforeChanges = List.of(
                "differentLine1",
                "differentLine2",
                "sameLine1",
                "sameLine2",
                "differentLine3",
                "differentLine4",
                "sameLine1",
                "sameLine2"
);
List<String> afterChanges = List.of(
                "newDifferentLine1",
                "newDifferentLine2",
                "sameLine1",
                "sameLine2"
);
var deltas = DiffUtils.diff(beforeChanges, afterChanges, true).getDeltas();

I'm attaching screens how this operation looks in github and how looks output from DiffUtils

Image

Image

Can you please fix the way the Diffs are calculated to match Git?

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.