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

[RFC] Representation of diff with trailing spaces

From
SBSébastien BRUCKERT <sebastien.bruckert@smile.fr>
Date
Mar 26, 2020, 11:07 UTC
Message-ID
<CABt=S26FB1zkwDCdmXeyVvFYvpvuGSX_y1Fg5N3K=yq0ZMyR7A@mail.gmail.com>
Hello everyone,
This is my first RFC, I hope it is correct. Do not hesitate to correct me.

# Problem Trailing spaces are represented only when added in the diff, and not when removed.

# Abstract Something that always bothered me with git diff was how trailing spaces are represented. If I add spaces, then diff, they are represented in the terminal by a red background. If I then remove them, they are not represented. That's how I can have a diff with two exact lines, and I'm looking for the diff in it, but can't find it. Because it is the non-represented spaces.

# Reproducibility One picture is worth a thousand words, here is a little snippet of shell to see this by yourself: ``` mkdir test cd test

git init

cat << EOF > file This file contains line at the end before fix. EOF

git add file git diff --staged

sed -i 's/[[:blank:]]*$//' file

git add -p ```

# Solution proposed Show the trailing spaces in a diff when removed. No performance impact expected,

# Open point Maybe we could argue on which color for added trailing spaces, and removed ones, to differentiate them quickly in a big diff. For the moment, added spaces are red. Maybe they should be green, and removed should be red. Or the opposite. Or everything in red.

Thank you for taking the time to review my proposal!
Next: Jeff King
Message 1 of 3 in “[RFC] Representation of diff with trailing spaces”
  1. Sébastien BRUCKERTMar 26, 2020
  2. Jeff KingMar 26, 2020
  3. Sébastien BRUCKERTMar 26, 2020

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.