git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Sébastien BRUCKERT" <sebastien.bruckert@smile.fr>
To: git@vger.kernel.org
Subject: [RFC] Representation of diff with trailing spaces
Date: Thu, 26 Mar 2020 12:07:55 +0100	[thread overview]
Message-ID: <CABt=S26FB1zkwDCdmXeyVvFYvpvuGSX_y1Fg5N3K=yq0ZMyR7A@mail.gmail.com> (raw)

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!

             reply	other threads:[~2020-03-26 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 11:07 Sébastien BRUCKERT [this message]
2020-03-26 11:15 ` [RFC] Representation of diff with trailing spaces Jeff King
2020-03-26 12:40   ` Sébastien BRUCKERT

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABt=S26FB1zkwDCdmXeyVvFYvpvuGSX_y1Fg5N3K=yq0ZMyR7A@mail.gmail.com' \
    --to=sebastien.bruckert@smile.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).