From a06eae62374060fb3f9f841bbd20568a44c0748d Mon Sep 17 00:00:00 2001 From: gdh Date: Thu, 3 May 2018 13:57:19 +0000 Subject: [PATCH] Another attempt to fix problems with line 0 in git-patch --- misc.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/misc.php b/misc.php index e20c7a7a8..155a7effc 100644 --- a/misc.php +++ b/misc.php @@ -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; }