The intended use of the --git-base is something like phpcs-changed --git --git-base=master files... to find only the issues that have been added since the current branch was branched from master.
This is accomplished by running phpcs against the version of each file from master and from HEAD, and using git diff master...HEAD to get a diff to correct line number discrepancies.
The problem is that git diff master...HEAD compares the merge-base of master and HEAD with the version in HEAD, but phpcs-changed is run against the version in master itself. If there are changes in master that have not yet been merged into HEAD, the diff will not reflect them but the phpcs run will, which can break the line number correction and cause existing warnings to be incorrectly reported.
Test case
Unpack test.tar.gz and cd into the unpacked directory.
FILE: test.php
-----------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 0 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------
9 | ERROR | Space after opening parenthesis of function call prohibited
9 | ERROR | Expected 0 spaces before closing parenthesis; 1 found
-----------------------------------------------------------------------------------------------
The intended use of the
--git-base
is something likephpcs-changed --git --git-base=master files...
to find only the issues that have been added since the current branch was branched from master.This is accomplished by running phpcs against the version of each file from master and from HEAD, and using
git diff master...HEAD
to get a diff to correct line number discrepancies.The problem is that
git diff master...HEAD
compares the merge-base of master and HEAD with the version in HEAD, but phpcs-changed is run against the version in master itself. If there are changes in master that have not yet been merged into HEAD, the diff will not reflect them but the phpcs run will, which can break the line number correction and cause existing warnings to be incorrectly reported.Test case
composer install
vendor/bin/phpcs-changed --git --git-base=test/base test.php
Expected output
No output. Command exits with code 0.
Actual output
Command exits with code 1.