From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6194 invoked by alias); 19 Dec 2013 00:19:53 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 6183 invoked by uid 89); 19 Dec 2013 00:19:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f46.google.com Received: from mail-wg0-f46.google.com (HELO mail-wg0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 19 Dec 2013 00:19:22 +0000 Received: by mail-wg0-f46.google.com with SMTP id m15so376310wgh.13 for ; Wed, 18 Dec 2013 16:19:19 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.37.112 with SMTP id x16mr235646wij.48.1387412359530; Wed, 18 Dec 2013 16:19:19 -0800 (PST) Received: by 10.216.236.71 with HTTP; Wed, 18 Dec 2013 16:19:19 -0800 (PST) Date: Thu, 19 Dec 2013 00:19:00 -0000 Message-ID: Subject: Trailing Whitespace From: Ben Longbons To: GDB Development Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2013-12/txt/msg00056.txt.bz2 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