From: Ben Longbons <brlongbons@gmail.com>
To: GDB Development <gdb@sourceware.org>
Subject: Trailing Whitespace
Date: Thu, 19 Dec 2013 00:19:00 -0000 [thread overview]
Message-ID: <CA+XNFZP6JzmOGo=nQDd4kab8RK1zvR4sij_zgS7qdPw7C1W9Vw@mail.gmail.com> (raw)
As I've tried, .
I have my editor set to trim all trailing whitespace, because trailing
whitespace is never desirable.
However, since other people have in times past committed code that
*does* contain trailing whitespace, this creates noise when I'm trying
to create a patch.
Therefore, I suggest that someone create a commit that removes all the
trailing whitespace. The pressing need is to apply this to gdb/ but
there is no reason it couldn't be applied to other parts if need be.
A commit that does nothing besides change trailing whitespace is *not*
harmful to the history, because git-blame and other tools can all
ignore whitespace.
Therefore, the only consideration is whether this will cause problems
for people with changes that are not yet committed in the main repo.
The script at the end of this message demonstrates how to avoid
problems with all 4 of the local branch strategies that I know about.
But first, the script to clean up after it:
#!/bin/bash -eu
# clean.sh
# Make the directory effectively empty
read -p 'Press enter to rm a bunch of directories, ^C to cancel'
rm -rf remote
rm -rf init
rm -rf whitespace
for repo in retv args
do
rm -rf $repo
for strategy in merge rebase git_patch dumb_patch
do
rm -rf $repo-$strategy
done
done
#!/bin/bash -eu
# dirty.sh
# Run from an effectively empty directory
! test -f remote
! test -f init
! test -f whitespace
for repo in retv args
do
! test -f $repo
for strategy in merge rebase git_patch dumb_patch
do
! test -f $repo-$strategy
done
done
# first set up the repo and contents
git init --bare remote
git clone remote init
cd init
echo 'int main() { ' > file.c
echo ' return 0;' >> file.c
echo '}' >> file.c
git add file.c
git commit -m 'init'
git push origin master
cd ..
# Two different cases representing people's non-committed changes.
# one is diff on the same line and one is on a nearby line
git clone remote retv
cd retv
sed 's/0/1/' -i file.c
git add -u
git commit -m retv
git branch retv # for backup
cd ..
git clone remote args
cd args
sed 's/()/(int argc, char **argv)/' -i file.c
git commit -a -m args
git branch args # for backup
cd ..
# Then make the whitespace change
git clone remote whitespace
cd whitespace
sed 's/[[:space:]]\+$//' -i file.c
git commit -a -m 'whitespace'
git push
cd ..
strategy_merge() {
# cannot be used until we ditch changelogs
# preferred strategy for many projects
git pull -X ignore-space-at-eol --no-edit
}
strategy_rebase() {
# best approach given changelogs
# preferred strategy for many projects
git pull --rebase -X ignore-space-at-eol
}
strategy_git_patch() {
# historical approach from when patches had to be mailed around
# still works fairly well
git format-patch HEAD^
git fetch
git reset --hard origin/master
git am --ignore-whitespace 0001-$repo.patch
}
strategy_dumb_patch() {
# not recommended - no advantages, several disadvantages over git_patch
git show > dumb.diff
git fetch
git reset --hard origin/master
patch --ignore-whitespace -p1 < dumb.diff
git add -u
git commit -m $repo
}
for repo in retv args
do
for strategy in merge rebase git_patch dumb_patch
do
echo in $repo, using $strategy
cp -a $repo $repo-$strategy
cd $repo-$strategy
strategy_$strategy
cd ..
done
done
echo Done
next reply other threads:[~2013-12-19 0:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 0:19 Ben Longbons [this message]
2014-01-09 14:45 ` Gary Benson
2014-01-09 14:57 ` Phil Muldoon
2014-01-09 15:01 ` Joel Brobecker
2014-01-09 18:46 ` Dmitry Samersoff
2014-01-10 3:44 ` Samuel Bronson
2014-01-10 4:00 ` Joel Brobecker
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='CA+XNFZP6JzmOGo=nQDd4kab8RK1zvR4sij_zgS7qdPw7C1W9Vw@mail.gmail.com' \
--to=brlongbons@gmail.com \
--cc=gdb@sourceware.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