Skip to content

Too many lines considered changed when 0 lines were added #14

@wskz-adam

Description

@wskz-adam

Hi there!

I've noticed that when the git diff -U0 output is @@ -3 +2,0 @@, so there's been one line removed and none added, the getChangedLinesPerFile method decides to create a range of lines instead of just one line. In this specific case the lines defined as changed are 1 and 2, but of course line 1 has not been touched at all.

The issue is probably the fact that the getChangedLinesPerFile thinks that multiple lines have been changed. Whenever there's a value after the coma in the added lines section of a git diff (+2,0 in this case), it recalculates the end line and in my case the result is 1 ($end = 2 - 0 - 1 as in $end = $start + $length - 1;).

Looks like value 0 should share the behaviour with null value, so whether the git diff outputs @@ -3 +2,0 @@ or @@ -3 +2 @@ the final result should be the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions