{"thread":{"id":"62175","subject":"Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move","startedAt":"2024-09-23T16:34:54Z","lastAt":"2024-09-23T22:32:42Z","messageCount":3,"participants":["Ian Turner","René Scharfe","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"503264","messageId":"d8512f2b-400f-4daa-a59f-5d10d4fc3840@vectro.org","threadId":"62175","inReplyTo":null,"subject":"Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move","fromName":"Ian Turner","fromEmail":"vectro@vectro.org","sentAt":"2024-09-23T16:29:06Z","receivedAt":"2024-09-23T16:34:54Z","isPatch":false,"sender":{"key":"vectro@vectro.org","avatar":null},"body":"Hi all,\n\nI noticed that there an undocumented interaction of the --exit-code and \n--ignore-space-change flags to git diff, when the diff only contains \nfile moves. Specifically, --ignore-space-change will cause git diff to \nreturn a zero exit code in this situation.\n\nI am not sure if the problem is with the command behavior, or with the \ndocumentation.\n\nSTEPS TO REPRODUCE:\n\ngit init\necho foo > a.txt\ngit add a.txt\ngit commit -m \"A\"\ngit mv a.txt b.txt\ngit commit -m \"B\"\ngit diff --exit-code HEAD~1..HEAD # returns exit code 1\ngit diff --exit-code --ignore-space-change HEAD~1..HEAD # returns exit \nstatus 0\n\nEXPECTED BEHAVIOR:\n\nBoth of the last two commands above should return nonzero exit status.\n\nWORKAROUND:\n\nAs one might expect --no-renames undoes this behavior, although it also \nchanges the diff output if not using --quiet:\n\ngit diff --exit-code --ignore-space-change --no-renames HEAD~1..HEAD # \nreturns exit status 1\n\nOTHER INFO:\n\nTested this on git 2.39.2 and git 2.41.0, both on Linux.\n\nRegards,\n\nIan Turner\n\n"},{"id":"503273","messageId":"2c3472d4-ad40-4636-9840-51fa97bca02b@web.de","threadId":"62175","inReplyTo":"d8512f2b-400f-4daa-a59f-5d10d4fc3840@vectro.org","subject":"Re: Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2024-09-23T18:08:58Z","receivedAt":"2024-09-23T18:09:05Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 23.09.24 um 18:29 schrieb Ian Turner:\n> I noticed that there an undocumented interaction of the --exit-code\n> and --ignore-space-change flags to git diff, when the diff only\n> contains file moves. Specifically, --ignore-space-change will cause\n> git diff to return a zero exit code in this situation.\n>\n> I am not sure if the problem is with the command behavior, or with\n> the documentation.\n>\n> STEPS TO REPRODUCE:\n>\n> git init\n> echo foo > a.txt\n> git add a.txt\n> git commit -m \"A\"\n> git mv a.txt b.txt\n> git commit -m \"B\"\n> git diff --exit-code HEAD~1..HEAD # returns exit code 1\n> git diff --exit-code --ignore-space-change HEAD~1..HEAD # returns exit status 0\n>\n> EXPECTED BEHAVIOR:\n>\n> Both of the last two commands above should return nonzero exit status.\n>\n> WORKAROUND:\n>\n> As one might expect --no-renames undoes this behavior, although it\n> also changes the diff output if not using --quiet:\n>\n> git diff --exit-code --ignore-space-change --no-renames HEAD~1..HEAD # returns exit status 1\n>\n> OTHER INFO:\n>\n> Tested this on git 2.39.2 and git 2.41.0, both on Linux.\n\nThank you for the report!  It's a known bug in the code.\n\nd7b97b7185 (diff: let external diffs report that changes are\nuninteresting, 2024-06-09) exposed it more widely, unfortunately,\ncausing v2.46.0 and up to report the wrong exit code even without\n--ignore-space-change.\n\n87cf96094a (diff: report copies and renames as changes in\nrun_diff_cmd(), 2024-09-08) fixes it, but it's not in any release, yet.\n\nRené\n\n"},{"id":"503294","messageId":"xmqqzfnyvw54.fsf@gitster.g","threadId":"62175","inReplyTo":"2c3472d4-ad40-4636-9840-51fa97bca02b@web.de","subject":"Re: Bug report: Undocumented interaction of --exit-code and --ignore-space-change for file move","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-09-23T22:32:39Z","receivedAt":"2024-09-23T22:32:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> 87cf96094a (diff: report copies and renames as changes in\n> run_diff_cmd(), 2024-09-08) fixes it, but it's not in any release, yet.\n\nThanks.\n\nIt should first appear in Git 2.46.2 and would be in Git 2.47.\n"}]}