[libvirt] consistency: push "update" hook vs. "make syntax-check"
Jim Meyering
jim at meyering.net
Thu Jul 16 07:10:17 UTC 2009
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 at 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.
---
COPYING.LIB | 2 --
NEWS | 1 -
acinclude.m4 | 1 -
.../0001-Step-1-of-8-Define-the-public-API.patch | 1 -
...tep-2-of-8-Define-the-internal-driver-API.patch | 1 -
...0003-Step-3-of-8-Implement-the-public-API.patch | 1 -
...ep-4-of-8-Define-the-wire-protocol-format.patch | 1 -
...0005-Step-5-of-8-Implement-the-RPC-client.patch | 1 -
...of-8-Implement-the-server-side-dispatcher.patch | 1 -
...-Step-7-of-8-Implement-the-driver-methods.patch | 1 -
.../0008-Step-8-of-8-Add-virsh-support.patch | 1 -
docs/devhelp/devhelp.xsl | 2 --
docs/devhelp/html.xsl | 2 --
docs/examples/python/README | 1 -
docs/examples/python/dominfo.py | 2 --
docs/library.xen | 1 -
docs/news.xsl | 1 -
docs/schemas/capability.rng | 1 -
docs/testnetdef.xml | 1 -
docs/testnetpriv.xml | 1 -
examples/domain-events/events-python/event-test.py | 1 -
python/libvirt_wrap.h | 1 -
qemud/THREADING.txt | 1 -
qemud/libvirtd_qemu.aug | 1 -
src/logging.c | 1 -
src/lxc_conf.h | 1 -
src/network_conf.c | 1 -
src/network_conf.h | 1 -
src/nodeinfo.c | 2 --
src/opennebula/one_client.c | 2 --
src/opennebula/one_client.h | 2 --
src/opennebula/one_conf.c | 1 -
src/opennebula/one_conf.h | 1 -
src/qemu_conf.c | 1 -
src/storage_backend.c | 1 -
src/vbox/vbox_XPCOMCGlue.c | 1 -
src/vbox/vbox_XPCOMCGlue.h | 1 -
src/veth.c | 1 -
tests/capabilityschemadata/caps-qemu-kvm.xml | 2 --
tests/capabilityschemadata/caps-test.xml | 2 --
tests/confdata/libvirtd.conf | 2 --
...ge_serial_3600c0ff000d7a2a5d463ff4902000000.xml | 2 --
tests/nodeinfodata/linux-nodeinfo-1.cpuinfo | 1 -
tests/nodeinfodata/linux-nodeinfo-2.cpuinfo | 1 -
tests/nodeinfodata/linux-nodeinfo-4.cpuinfo | 1 -
tests/nodeinfodata/linux-nodeinfo-5.cpuinfo | 1 -
tests/nodeinfodata/linux-nodeinfo-6.cpuinfo | 1 -
tests/nodeinfotest.c | 1 -
tests/object-locking.ml | 2 --
tests/reconnect.c | 1 -
tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-disk-block.sexpr | 1 -
.../sexpr2xml-disk-drv-blktap-qcow.sexpr | 1 -
.../sexpr2xml-disk-drv-blktap-raw.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-disk-file.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-net-bridged.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-net-e1000.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-net-routed.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-pci-devs.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-pv-localtime.sexpr | 1 -
.../sexpr2xml-pv-vfb-new-vncdisplay.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.sexpr | 1 -
tests/sexpr2xmldata/sexpr2xml-pv.sexpr | 1 -
tests/sexpr2xmltest.c | 1 -
tests/storagepoolschemadata/pool-fs.xml | 1 -
tests/storagepoolschemadata/pool-netfs.xml | 1 -
tests/storagevolschemadata/vol-logical.xml | 1 -
tests/testutilsqemu.h | 1 -
tests/testutilsxen.h | 1 -
tests/xencapsdata/xen-i686-pae-hvm.cpuinfo | 1 -
tests/xencapsdata/xen-i686-pae.cpuinfo | 2 --
tests/xencapsdata/xen-i686.cpuinfo | 1 -
tests/xencapstest.c | 1 -
tests/xmconfigtest.c | 1 -
tests/xml2sexprdata/xml2sexpr-bridge-ipaddr.xml | 1 -
.../xml2sexpr-disk-block-shareable.xml | 1 -
tests/xml2sexprdata/xml2sexpr-disk-block.xml | 1 -
tests/xml2sexprdata/xml2sexpr-disk-drv-blkback.xml | 1 -
.../xml2sexpr-disk-drv-blktap-qcow.xml | 1 -
.../xml2sexpr-disk-drv-blktap-raw.xml | 1 -
tests/xml2sexprdata/xml2sexpr-disk-drv-blktap.xml | 1 -
tests/xml2sexprdata/xml2sexpr-disk-drv-loop.xml | 1 -
tests/xml2sexprdata/xml2sexpr-disk-file.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-kernel.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-localtime.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-file.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-null.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-pty.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.xml | 1 -
.../xml2sexpr-fv-serial-tcp-telnet.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-udp.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-serial-unix.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-sound.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-usbmouse.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-usbtablet.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-utc.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv-vncunused.xml | 1 -
tests/xml2sexprdata/xml2sexpr-fv.xml | 1 -
tests/xml2sexprdata/xml2sexpr-net-bridged.xml | 1 -
tests/xml2sexprdata/xml2sexpr-net-e1000.xml | 1 -
tests/xml2sexprdata/xml2sexpr-net-routed.xml | 1 -
tests/xml2sexprdata/xml2sexpr-pci-devs.xml | 1 -
tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml | 1 -
tests/xml2sexprdata/xml2sexpr-pv.xml | 1 -
tests/xml2sexprtest.c | 1 -
109 files changed, 0 insertions(+), 122 deletions(-)
...
>From 9d93638ab94709f5a5f5b48db506e1d0afbe3504 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Thu, 16 Jul 2009 09:06:58 +0200
Subject: [PATCH 2/2] make "make syntax-check" consistent with "git diff --check"
This makes "make syntax-check" fail when a version-controlled
file contains a trailing blank line.
* cfg.mk (sc_prohibit_trailing_blank_lines): New rule.
---
cfg.mk | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 3b3d57f..0bf935d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -228,6 +228,15 @@ sc_libvirt_unmarked_diagnostics:
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
+# Disallow trailing blank lines.
+sc_prohibit_trailing_blank_lines:
+ @$(VC_LIST_EXCEPT) | xargs perl -ln -0777 -e \
+ '/\n\n+$$/ and print $$ARGV' > $@-t
+ @found=0; test -s $@-t && { found=1; cat $@-t 1>&2; \
+ echo '$(ME): found trailing blank line(s)' 1>&2; }; \
+ rm -f $@-t; \
+ test $$found = 0
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
--
1.6.4.rc0.127.g81400
More information about the libvir-list
mailing list