"git diff --no-pager --exit-code" errors out but returns zero exit code
- From
- Romain Chossart <romainchossart@gmail.com>
- Date
- Aug 20, 2023, 19:52 UTC
- Message-ID
- <CAHxTZ4AUxow1p7mNG0fuRtfhkaOu=Wpc7cYvM8wRaB80hPNf9Q@mail.gmail.com>
I recently found out (the hard way :-) ) that running the following command prints an appropriate error on stderr but returns a zero exit code:
> $ git diff --no-pager --exit-code > error: invalid option: --no-pager > $ echo $? > 0
I would expect a non-zero exit code to be returned.
Interestingly, running `git diff --no-pager --exit-code HEAD` shows a usage instead and does return a non-zero exit code as expected.
Thanks,
-- Romain Chossart