On Thu, Jul 16, 2009 at 09:10:17AM +0200, Jim Meyering wrote:
Jim Meyering wrote:
> Currently the server side hook that runs "git diff --check"
> to prevent pushing a change that adds trailing blanks is
> more strict than our "make syntax-check" hook, since the former
> rejects any change that adds blank lines at the end of a file,
> while "make syntax-check" doesn't complain about that.
>
> The two should be consistent.
> One way is to make "make syntax-check" more strict.
> If we were to do that, we'd have to choose between
> cleaning existing files and exempting them from the new test.
> Cleaning is easy and doesn't impact tests at all, so I prefer it.
>
> Here's what would be involved:
>
> - remove 121 trailing newlines from 109 files by running this command:
> git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/'
>
> Add a rule to cfg.mk so that "make syntax-check" warns about
> any new violations. It might run something like this:
>
> git ls-files -z \
> | xargs -0 perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV:
".length $1'
>
> That command prints the name of each offending file with its trailing
> blank line count. While it takes well under a second on my system,
> (admittedly, with a hot cache), it's not well optimized, reading
> each file into memory and processing it.
Here are two change-sets to implement that.
The first just removes all trailing blank line, so I've
omitted its boring 100+ diffs.
>From 90046bad3bb688f8bfddfedcf3b681cf9b99028d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 16 Jul 2009 08:25:36 +0200
Subject: [PATCH 1/2] remove all trailing blank lines
by running this command:
git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/'
This is in preparation for a more strict make syntax-check
rule that will detect trailing blank lines.
ACK
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|