git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bug report - `git diff --quiet --cached` returns 0 when a rename is staged
@ 2024-09-06 23:12 Jorge Luis Martinez Gomez
  2024-09-08  7:04 ` René Scharfe
  0 siblings, 1 reply; 2+ messages in thread
From: Jorge Luis Martinez Gomez @ 2024-09-06 23:12 UTC (permalink / raw)
  To: git

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

  $ mkdir /tmp/git-diff-test; cd /tmp/git-diff-test
  $ git init 
  Initialized empty Git repository in /tmp/git-diff-test/.git/
  $ touch foo 
  $ git add foo 
  $ git commit -m "foo"
  [main (root-commit) f60d7bc] foo
   1 file changed, 0 insertions(+), 0 deletions(-)
   create mode 100644 foo
  $ mv foo bar 
  $ git status -s
   D foo
  ?? bar
  $ git add foo bar 
  $ git status -s
  R  foo -> bar
  $ git diff --quiet --cached; echo $?
  0
  $ git diff --quiet --cached --no-renames; echo $?
  1

What did you expect to happen? (Expected behavior)

  Versions prior to commit d7b97b7185521e3b9364b3abc6553df2480da173
  returned 1 for `git diff --quiet --cached`.

What happened instead? (Actual behavior)

  It returned 0.

What's different between what you expected and what actually happened?

  The status code.

Anything else you want to add:

  This bug report originates from a PR I filed with Magit here:

  https://github.com/magit/magit/pull/5221

  I thought this difference between using `--no-renames` and not made
  sense, so I thought the problem lied with Magit. However, like tarsius in
  that thread points out, this is a change that happened recently with git
  and it's not in the release notes. After finding the commit that
  introduces the change, I see the message mentions "The new options are
  off by default, keeping the old behavior." It really doesn't seem
  intentional, so here's a bug report.

  Also, the above difference with --no-renames also happens if I move my
  ~/.gitconfig elsewhere, so there's no use of external diff tools. I
  verified that with strace, too.

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.46.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.9.0
OpenSSL: OpenSSL 3.3.1 4 Jun 2024
zlib: 1.3.1
uname: Linux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64
compiler info: gnuc: 14.1
libc info: glibc: 2.40
$SHELL (typically, interactive shell): /usr/bin/zsh


[Enabled Hooks]

-- 
  Jorge Luis Martinez Gomez
  jol@jol.dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bug report - `git diff --quiet --cached` returns 0 when a rename is staged
  2024-09-06 23:12 bug report - `git diff --quiet --cached` returns 0 when a rename is staged Jorge Luis Martinez Gomez
@ 2024-09-08  7:04 ` René Scharfe
  0 siblings, 0 replies; 2+ messages in thread
From: René Scharfe @ 2024-09-08  7:04 UTC (permalink / raw)
  To: Jorge Luis Martinez Gomez, git

Am 07.09.24 um 01:12 schrieb Jorge Luis Martinez Gomez:
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
>   $ mkdir /tmp/git-diff-test; cd /tmp/git-diff-test
>   $ git init
>   Initialized empty Git repository in /tmp/git-diff-test/.git/
>   $ touch foo
>   $ git add foo
>   $ git commit -m "foo"
>   [main (root-commit) f60d7bc] foo
>    1 file changed, 0 insertions(+), 0 deletions(-)
>    create mode 100644 foo
>   $ mv foo bar
>   $ git status -s
>    D foo
>   ?? bar
>   $ git add foo bar
>   $ git status -s
>   R  foo -> bar
>   $ git diff --quiet --cached; echo $?
>   0
>   $ git diff --quiet --cached --no-renames; echo $?
>   1
>
> What did you expect to happen? (Expected behavior)
>
>   Versions prior to commit d7b97b7185521e3b9364b3abc6553df2480da173
>   returned 1 for `git diff --quiet --cached`.

Thanks a lot for the reproduction recipe and for bisecting it!

> What happened instead? (Actual behavior)
>
>   It returned 0.
>
> What's different between what you expected and what actually happened?
>
>   The status code.
>
> Anything else you want to add:
>
>   This bug report originates from a PR I filed with Magit here:
>
>   https://github.com/magit/magit/pull/5221
>
>   I thought this difference between using `--no-renames` and not made
>   sense, so I thought the problem lied with Magit. However, like tarsius in
>   that thread points out, this is a change that happened recently with git
>   and it's not in the release notes. After finding the commit that
>   introduces the change, I see the message mentions "The new options are
>   off by default, keeping the old behavior." It really doesn't seem
>   intentional, so here's a bug report.

Indeed, that's a bug.  Affects copies as well.  And could be triggered by
e.g. --ignore-space-change or --ignore-matching-lines before, like the
submodule diff regression reported earlier.

René


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-08  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 23:12 bug report - `git diff --quiet --cached` returns 0 when a rename is staged Jorge Luis Martinez Gomez
2024-09-08  7:04 ` René Scharfe

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 NNTP newsgroup(s).