git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bug report - `git diff --quiet --cached` returns 0 when a rename is staged

From
René Scharfe <l.s.r@web.de>
Date
Sep 8, 2024, 07:04 UTC
Message-ID
<b21d74b6-aa51-474a-a8be-40dc1de94bc3@web.de>
In-Reply-To
<0241cbcc-11b3-483a-8a63-d523291b92ff@app.fastmail.com>
Am 07.09.24 um 01:12 schrieb Jorge Luis Martinez Gomez:
Show 30 quoted lines
> 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!
Show 21 quoted lines
> 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é
Previous: Jorge Luis Martinez Gomez
Message 2 of 2 in “bug report - `git diff --quiet --cached` returns 0 when a rename is staged”
  1. Jorge Luis Martinez GomezSep 6, 2024
  2. René ScharfeSep 8, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.