{"thread":{"id":"62076","subject":"bug report - `git diff --quiet --cached` returns 0 when a rename is staged","startedAt":"2024-09-06T23:13:43Z","lastAt":"2024-09-08T07:04:21Z","messageCount":2,"participants":["Jorge Luis Martinez Gomez","René Scharfe"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"502378","messageId":"0241cbcc-11b3-483a-8a63-d523291b92ff@app.fastmail.com","threadId":"62076","inReplyTo":null,"subject":"bug report - `git diff --quiet --cached` returns 0 when a rename is staged","fromName":"Jorge Luis Martinez Gomez","fromEmail":"jol@jol.dev","sentAt":"2024-09-06T23:12:02Z","receivedAt":"2024-09-06T23:13:43Z","isPatch":false,"sender":{"key":"jol@jol.dev","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n  $ mkdir /tmp/git-diff-test; cd /tmp/git-diff-test\n  $ git init \n  Initialized empty Git repository in /tmp/git-diff-test/.git/\n  $ touch foo \n  $ git add foo \n  $ git commit -m \"foo\"\n  [main (root-commit) f60d7bc] foo\n   1 file changed, 0 insertions(+), 0 deletions(-)\n   create mode 100644 foo\n  $ mv foo bar \n  $ git status -s\n   D foo\n  ?? bar\n  $ git add foo bar \n  $ git status -s\n  R  foo -> bar\n  $ git diff --quiet --cached; echo $?\n  0\n  $ git diff --quiet --cached --no-renames; echo $?\n  1\n\nWhat did you expect to happen? (Expected behavior)\n\n  Versions prior to commit d7b97b7185521e3b9364b3abc6553df2480da173\n  returned 1 for `git diff --quiet --cached`.\n\nWhat happened instead? (Actual behavior)\n\n  It returned 0.\n\nWhat's different between what you expected and what actually happened?\n\n  The status code.\n\nAnything else you want to add:\n\n  This bug report originates from a PR I filed with Magit here:\n\n  https://github.com/magit/magit/pull/5221\n\n  I thought this difference between using `--no-renames` and not made\n  sense, so I thought the problem lied with Magit. However, like tarsius in\n  that thread points out, this is a change that happened recently with git\n  and it's not in the release notes. After finding the commit that\n  introduces the change, I see the message mentions \"The new options are\n  off by default, keeping the old behavior.\" It really doesn't seem\n  intentional, so here's a bug report.\n\n  Also, the above difference with --no-renames also happens if I move my\n  ~/.gitconfig elsewhere, so there's no use of external diff tools. I\n  verified that with strace, too.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.46.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 8.9.0\nOpenSSL: OpenSSL 3.3.1 4 Jun 2024\nzlib: 1.3.1\nuname: Linux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64\ncompiler info: gnuc: 14.1\nlibc info: glibc: 2.40\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n\n[Enabled Hooks]\n\n-- \n  Jorge Luis Martinez Gomez\n  jol@jol.dev\n"},{"id":"502406","messageId":"b21d74b6-aa51-474a-a8be-40dc1de94bc3@web.de","threadId":"62076","inReplyTo":"0241cbcc-11b3-483a-8a63-d523291b92ff@app.fastmail.com","subject":"Re: bug report - `git diff --quiet --cached` returns 0 when a rename is staged","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2024-09-08T07:04:10Z","receivedAt":"2024-09-08T07:04:21Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 07.09.24 um 01:12 schrieb Jorge Luis Martinez Gomez:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>\n>   $ mkdir /tmp/git-diff-test; cd /tmp/git-diff-test\n>   $ git init\n>   Initialized empty Git repository in /tmp/git-diff-test/.git/\n>   $ touch foo\n>   $ git add foo\n>   $ git commit -m \"foo\"\n>   [main (root-commit) f60d7bc] foo\n>    1 file changed, 0 insertions(+), 0 deletions(-)\n>    create mode 100644 foo\n>   $ mv foo bar\n>   $ git status -s\n>    D foo\n>   ?? bar\n>   $ git add foo bar\n>   $ git status -s\n>   R  foo -> bar\n>   $ git diff --quiet --cached; echo $?\n>   0\n>   $ git diff --quiet --cached --no-renames; echo $?\n>   1\n>\n> What did you expect to happen? (Expected behavior)\n>\n>   Versions prior to commit d7b97b7185521e3b9364b3abc6553df2480da173\n>   returned 1 for `git diff --quiet --cached`.\n\nThanks a lot for the reproduction recipe and for bisecting it!\n\n> What happened instead? (Actual behavior)\n>\n>   It returned 0.\n>\n> What's different between what you expected and what actually happened?\n>\n>   The status code.\n>\n> Anything else you want to add:\n>\n>   This bug report originates from a PR I filed with Magit here:\n>\n>   https://github.com/magit/magit/pull/5221\n>\n>   I thought this difference between using `--no-renames` and not made\n>   sense, so I thought the problem lied with Magit. However, like tarsius in\n>   that thread points out, this is a change that happened recently with git\n>   and it's not in the release notes. After finding the commit that\n>   introduces the change, I see the message mentions \"The new options are\n>   off by default, keeping the old behavior.\" It really doesn't seem\n>   intentional, so here's a bug report.\n\nIndeed, that's a bug.  Affects copies as well.  And could be triggered by\ne.g. --ignore-space-change or --ignore-matching-lines before, like the\nsubmodule diff regression reported earlier.\n\nRené\n\n"}]}