{"thread":{"id":"53107","subject":"[RFC] Representation of diff with trailing spaces","startedAt":"2020-03-26T11:08:09Z","lastAt":"2020-03-26T12:40:59Z","messageCount":3,"participants":["Sébastien BRUCKERT","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"394082","messageId":"CABt=S26FB1zkwDCdmXeyVvFYvpvuGSX_y1Fg5N3K=yq0ZMyR7A@mail.gmail.com","threadId":"53107","inReplyTo":null,"subject":"[RFC] Representation of diff with trailing spaces","fromName":"Sébastien BRUCKERT","fromEmail":"sebastien.bruckert@smile.fr","sentAt":"2020-03-26T11:07:55Z","receivedAt":"2020-03-26T11:08:09Z","isPatch":false,"sender":{"key":"sebastien.bruckert@smile.fr","avatar":null},"body":"Hello everyone,\n\nThis is my first RFC, I hope it is correct. Do not hesitate to correct me.\n\n# Problem\nTrailing spaces are represented only when added in the diff, and not\nwhen removed.\n\n\n# Abstract\nSomething that always bothered me with git diff was how trailing\nspaces are represented. If I add spaces, then diff, they are\nrepresented in the terminal by a red background. If I then remove\nthem, they are not represented. That's how I can have a diff with two\nexact lines, and I'm looking for the diff in it, but can't find it.\nBecause it is the non-represented spaces.\n\n# Reproducibility\nOne picture is worth a thousand words, here is a little snippet of\nshell to see this by yourself:\n```\nmkdir test\ncd test\n\ngit init\n\ncat << EOF > file\nThis file contains line at the end before fix.\nEOF\n\ngit add file\ngit diff --staged\n\nsed -i 's/[[:blank:]]*$//' file\n\ngit add -p\n```\n\n# Solution proposed\nShow the trailing spaces in a diff when removed.\nNo performance impact expected,\n\n# Open point\nMaybe we could argue on which color for added trailing spaces, and\nremoved ones, to differentiate them quickly in a big diff. For the\nmoment, added spaces are red. Maybe they should be green, and removed\nshould be red. Or the opposite. Or everything in red.\n\n\nThank you for taking the time to review my proposal!\n"},{"id":"394084","messageId":"20200326111500.GB4193632@coredump.intra.peff.net","threadId":"53107","inReplyTo":"CABt=S26FB1zkwDCdmXeyVvFYvpvuGSX_y1Fg5N3K=yq0ZMyR7A@mail.gmail.com","subject":"Re: [RFC] Representation of diff with trailing spaces","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-03-26T11:15:00Z","receivedAt":"2020-03-26T11:15:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 26, 2020 at 12:07:55PM +0100, Sébastien BRUCKERT wrote:\n\n> # Abstract\n> Something that always bothered me with git diff was how trailing\n> spaces are represented. If I add spaces, then diff, they are\n> represented in the terminal by a red background. If I then remove\n> them, they are not represented. That's how I can have a diff with two\n> exact lines, and I'm looking for the diff in it, but can't find it.\n> Because it is the non-represented spaces.\n\nHave you tried setting diff.wsErrorHighlight? By default we only\nhighlight whitespace problems in new lines, but it can be told to show\nthem in old lines or in context.\n\n-Peff\n"},{"id":"394086","messageId":"CABt=S24vy0QpuVHoXdzTcRb3r6mU1AdswrGxOPksdwdrBGpEBg@mail.gmail.com","threadId":"53107","inReplyTo":"20200326111500.GB4193632@coredump.intra.peff.net","subject":"Re: [RFC] Representation of diff with trailing spaces","fromName":"Sébastien BRUCKERT","fromEmail":"sebastien.bruckert@smile.fr","sentAt":"2020-03-26T12:40:43Z","receivedAt":"2020-03-26T12:40:59Z","isPatch":false,"sender":{"key":"sebastien.bruckert@smile.fr","avatar":null},"body":"> > # Abstract\n> > Something that always bothered me with git diff was how trailing\n> > spaces are represented. If I add spaces, then diff, they are\n> > represented in the terminal by a red background. If I then remove\n> > them, they are not represented. That's how I can have a diff with two\n> > exact lines, and I'm looking for the diff in it, but can't find it.\n> > Because it is the non-represented spaces.\n>\n> Have you tried setting diff.wsErrorHighlight? By default we only\n> highlight whitespace problems in new lines, but it can be told to show\n> them in old lines or in context.\n>\n> -Peff\n\nOh yes, that was what I was looking for, thank you Peff!\n\nWell, if there is a config for it then, no need to change anything.\n"}]}