Re: git bug report
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 8, 2023, 17:07 UTC
- Message-ID
- <xmqqbkfh8nu3.fsf@gitster.g>
- In-Reply-To
- <MW2PR12MB25558D1886C4AA2A95A5FC618709A@MW2PR12MB2555.namprd12.prod.outlook.com>
Paul Watson <pwatson2@wellmed.net> writes:
> 9:43:55.45 2023-08-04 C:\src\t\scripts>TYPE .\t1.txt > this is t1.txt
Show 8 quoted lines
> 9:43:57.92 2023-08-04 C:\src\t\scripts>TYPE .\t2.txt > this is t2.txt > > 9:43:58.04 2023-08-04 C:\src\t\scripts>"C:\Program Files\Git\cmd\git.exe" diff --exit-code --no-index --ignore-all-space --shortstat .\t1.txt .\t2.txt > 1 file changed, 1 insertion(+), 1 deletion(-) > > 9:43:58.14 2023-08-04 C:\src\t\scripts>ECHO %ERRORLEVEL% > 0
This is not specific to Windows port and it can be reproduced on a random Linux box.
$ echo one >1
$ echo two >2
$ git diff --no-index --shortstat 1 2; echo "<<$?>>"
1 file changed, 1 insertion(+), 1 deletion(-)
<<1>>
$ git diff --no-index --shortstat -w 1 2; echo "<<$?>>"
1 file changed, 1 insertion(+), 1 deletion(-)
<<0>>Note that I omitted "--exit-code" in the above reproduction, as it is always used in the no-index mode. There seems to be interaction with "-w" and not using "-p", as this is not limited to "--shortstat".
$ git diff --no-index -w --stat 1 2; echo "<<$?>>"
1 => 2 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
<<0>> $ git diff --no-index -w --numstat 1 2; echo "<<$?>>"
1 1 1 => 2
<<0>>All of the above that exits with 0 status will exit with 1 when -p is added to the command line.
Also, this is not limited to the no-index mode.
$ echo one >1
$ git add 1
$ echo two >1
$ git diff --exit-code --numstat 1; echo "<<$?>>"
1 1 1
<<1>>
$ git diff --exit-code --numstat -w 1; echo "<<$?>>"
1 1 1
<<0>>So the minimum reproduction seems to be
* the diff machinery is asked to do --exit-code (no-index
implicitly does it)
* -w is used
* -p is *not* used
* to compare two different files.Thanks for a bug report.
Patches welcome ;-)