public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move
@ 2024-09-23 16:29 Ian Turner
  2024-09-23 18:08 ` René Scharfe
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Turner @ 2024-09-23 16:29 UTC (permalink / raw)
  To: git

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


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

end of thread, other threads:[~2024-09-23 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 16:29 Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move Ian Turner
2024-09-23 18:08 ` René Scharfe
2024-09-23 22:32   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox