Skip to content

Commit

Permalink
Another attempt to fix problems with line 0 in git-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
gudmdharalds committed May 3, 2018
1 parent 4275b92 commit a06eae6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,22 @@ function vipgoci_patch_changed_lines(
}
}


/*
* In cases where there is just one line,
* make special arrangements. This needs
* to be fixed properly.
* In certain edge-cases, line 1 in the patch
* will refer to line 0 in the code, which
* is not what we want. In these cases, we
* simply hard-code line 1 in the patch to match
* with line 1 in the code.
*/
if (
( count( $lines_changed ) === 1 ) &&
( 1 === $lines_changed[0] )
( isset( $lines_changed[1] ) ) &&
(
( $lines_changed[1] === null ) ||
( $lines_changed[1] === 0 )
)
||
( ! isset( $lines_changed[1] ) )
) {
unset( $lines_changed[0] );
$lines_changed[1] = 1;
}

Expand Down

0 comments on commit a06eae6

Please sign in to comment.