Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: German Lashevich <german.lashevich@gmail.com>
To: git@vger.kernel.org
Subject: Possible git-diff bug when using exit-code with diff filters
Date: Sat, 20 Apr 2024 03:13:14 +0200	[thread overview]
Message-ID: <CACDhgro3KXD0O9ZdE1q46jmXE0O=vf-Z+ZX50WMqmRHAeowGAA@mail.gmail.com> (raw)

> 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

             reply	other threads:[~2024-04-20  1:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20  1:13 German Lashevich [this message]
2024-04-21 10:42 ` Possible git-diff bug when using exit-code with diff filters René Scharfe
2024-04-21 18:17   ` Junio C Hamano
2024-04-21 18:32     ` rsbecker
2024-04-21 19:09       ` Junio C Hamano
2024-04-21 20:18         ` rsbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACDhgro3KXD0O9ZdE1q46jmXE0O=vf-Z+ZX50WMqmRHAeowGAA@mail.gmail.com' \
    --to=german.lashevich@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).