Possible git-diff bug when using exit-code with diff filters
- From
- German Lashevich <german.lashevich@gmail.com>
- Date
- Apr 20, 2024, 01:13 UTC
- Message-ID
- <CACDhgro3KXD0O9ZdE1q46jmXE0O=vf-Z+ZX50WMqmRHAeowGAA@mail.gmail.com>
> What did you do before the bug happened? (Steps to reproduce your issue)
I configured a diff filter via gitattributes to use a custom script that, sometimes, can change the files being compared in a way that there are no differences between them. Then I used `git diff --exit-code` on the changed file.
> What did you expect to happen? (Expected behavior)
I expected `git diff --exit-code` to return 0, since there are no differences between the files after the filter is applied.
> What happened instead? (Actual behavior)
`git diff --exit-code` correctly produces no output, but returns 1.
> What's different between what you expected and what actually happened?
The difference is that `git diff --exit-code`, instead of returning 0, returns 1 even when there is no output.
> Anything else you want to add:
I have prepared a repository with a test case that reproduces the issue. You can find it at https://github.com/Zebradil/git-diff-exit-code-bug-repro The Readme file in the repository contains instructions on how to reproduce the issue.
[System Info] git version: 2.44.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.8.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 17 Apr 2024 15:20:28 +0000 x86_64 compiler info: gnuc: 13.2 libc info: glibc: 2.39 $SHELL (typically, interactive shell): /bin/zsh
Best regards, German Lashevich