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

Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move

From
ITIan Turner <vectro@vectro.org>
Date
Sep 23, 2024, 16:29 UTC
Message-ID
<d8512f2b-400f-4daa-a59f-5d10d4fc3840@vectro.org>
Hi all,

I noticed that there an undocumented interaction of the --exit-code and --ignore-space-change flags to git diff, when the diff only contains file moves. Specifically, --ignore-space-change will cause git diff to return a zero exit code in this situation.

I am not sure if the problem is with the command behavior, or with the documentation.

STEPS TO REPRODUCE:

git init echo foo > a.txt git add a.txt git commit -m "A" git mv a.txt b.txt git commit -m "B" git diff --exit-code HEAD~1..HEAD # returns exit code 1 git diff --exit-code --ignore-space-change HEAD~1..HEAD # returns exit status 0

EXPECTED BEHAVIOR:
Both of the last two commands above should return nonzero exit status.
WORKAROUND:

As one might expect --no-renames undoes this behavior, although it also changes the diff output if not using --quiet:

git diff --exit-code --ignore-space-change --no-renames HEAD~1..HEAD # returns exit status 1

OTHER INFO:
Tested this on git 2.39.2 and git 2.41.0, both on Linux.
Regards,
Ian Turner
Next: René Scharfe
Message 1 of 3 in “Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move”
  1. Ian TurnerSep 23, 2024
  2. René ScharfeSep 23, 2024
  3. Junio C HamanoSep 23, 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.