From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: emacs-diffs emails can get long subject if log starts with "*" Date: Sat, 22 Nov 2014 16:46:07 -0800 Organization: UCLA Computer Science Department Message-ID: <54712E4F.2010102@cs.ucla.edu> References: <87389azvuk.fsf@igel.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070701050304010000050400" X-Trace: ger.gmane.org 1416703619 14024 80.91.229.3 (23 Nov 2014 00:46:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Nov 2014 00:46:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 23 01:46:54 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XsLKI-0006Hp-DK for ged-emacs-devel@m.gmane.org; Sun, 23 Nov 2014 01:46:54 +0100 Original-Received: from localhost ([::1]:47313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsLKH-00073g-I0 for ged-emacs-devel@m.gmane.org; Sat, 22 Nov 2014 19:46:53 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsLJw-00073Z-6T for emacs-devel@gnu.org; Sat, 22 Nov 2014 19:46:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XsLJo-0005L7-FP for emacs-devel@gnu.org; Sat, 22 Nov 2014 19:46:32 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:59290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XsLJo-0005JB-48; Sat, 22 Nov 2014 19:46:24 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1CC4BA60012; Sat, 22 Nov 2014 16:46:16 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EBKOjy1Up84z; Sat, 22 Nov 2014 16:46:12 -0800 (PST) Original-Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net [71.177.17.123]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id DD65EA60001; Sat, 22 Nov 2014 16:46:11 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:178053 Archived-At: This is a multi-part message in MIME format. --------------070701050304010000050400 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To help avoid this sort of problem in future commits, I installed the attached patch into the emacs-24 branch. Once you bootstrap or run autogen.sh, it arranges for Git commit hooks that verify that a commit's file names are portable and that the commit messages are reasonable. It's common practice in other projects to have commit hooks with sanity checks. No doubt the details can use some tweaking for Emacs; this is just a first cut. --------------070701050304010000050400 Content-Type: text/x-diff; name="0001-Add-git-commit-hooks-that-do-some-simple-checks-on-c.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Add-git-commit-hooks-that-do-some-simple-checks-on-c.pa"; filename*1="tch" >From acd837f97f5701a3ebdb1bbdd79fac4ed8153629 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 22 Nov 2014 15:46:17 -0800 Subject: [PATCH] Add git commit hooks that do some simple checks on commits. * autogen.sh: Install Git hooks, if using Git. * build-aux/git-hooks/commit-msg, build-aux/git-hooks/pre-commit: New files, which are Git hooks that check for portable file names, and do some simple checks for commit message format. --- autogen.sh | 40 +++++++++++++++++++ build-aux/git-hooks/commit-msg | 90 ++++++++++++++++++++++++++++++++++++++++++ build-aux/git-hooks/pre-commit | 46 +++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100755 build-aux/git-hooks/commit-msg create mode 100755 build-aux/git-hooks/pre-commit diff --git a/autogen.sh b/autogen.sh index bc8a73d..69812cd 100755 --- a/autogen.sh +++ b/autogen.sh @@ -208,6 +208,46 @@ autoreconf -i -I m4 || exit $? ## cause 'make' to needlessly run 'autoheader'. echo timestamp > src/stamp-h.in || exit +## Install Git hooks, if using Git. +if test -d .git/hooks; then + tailored_hooks= + sample_hooks= + + for hook in commit-msg pre-commit; do + cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || + tailored_hooks="$tailored_hooks $hook" + done + for hook in applypatch-msg pre-applypatch; do + cmp .git/hooks/$hook.sample .git/hooks/$hook >/dev/null 2>&1 || + sample_hooks="$sample_hooks $hook" + done + + if test -n "$tailored_hooks$sample_hooks"; then + echo "Installing git hooks..." + + case `cp --help 2>/dev/null` in + *--backup*--verbose*) + cp_options='--backup=numbered --verbose';; + *) + cp_options='';; + esac + + if test -n "$tailored_hooks"; then + for hook in $tailored_hooks; do + cp $cp_options build-aux/git-hooks/$hook .git/hooks || exit + chmod a-w .git/hooks/$hook || exit + done + fi + + if test -n "$sample_hooks"; then + for hook in $sample_hooks; do + cp $cp_options .git/hooks/$hook.sample .git/hooks/$hook || exit + chmod a-w .git/hooks/$hook || exit + done + fi + fi +fi + echo "You can now run \`./configure'." exit 0 diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg new file mode 100755 index 0000000..6a09edd --- /dev/null +++ b/build-aux/git-hooks/commit-msg @@ -0,0 +1,90 @@ +#!/bin/sh +# Check the format of GNU Emacs change log entries. + +# Copyright 2014 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + +# Written by Paul Eggert. + +# Use a UTF-8 locale if available, so that the UTF-8 check works. +# Use U+00A2 CENT SIGN to test whether the locale works. +cent_sign_utf8_octal='\302\242' +at_sign=` + printf "${cent_sign_utf8_octal}@" | + awk '{print substr($0, 2)}' 2>/dev/null +` +if test "$at_sign" != @; then + at_sign=` + printf "${cent_sign_utf8_octal}@" | + LC_ALL=en_US.utf8 awk '{print substr($0, 2)}' 2>/dev/null + ` + if test "$at_sign" = @; then + LC_ALL=en_US.utf8; export LC_ALL + fi +fi + +# Check the log entry. +exec awk ' + /^#/ { next } + + !/^.*$/ { + print "Invalid character (not UTF-8)" + status = 1 + } + + nlines == 0 && !/[^[:space:]]/ { next } + + { nlines++ } + + nlines == 1 && /^[[:space:]]/ { + print "White space at start of first line" + status = 1 + } + + nlines == 2 && /[^[:space:]]/ { + print "Nonempty second line" + status = 1 + } + + /[[:cntrl:]]/ { + print "Text contains control character; please use spaces instead of tabs" + status = 1 + } + + 72 < length && /[[:space:]]/ { + print "Line longer than 72 characters" + status = 1 + } + + 140 < length { + print "Word longer than 140 characters" + status = 1 + } + + /^Signed-off-by: / { + print "'Signed-off-by:' present" + status = 1 + } + + END { + if (nlines == 0) { + print "Empty change log entry" + status = 1 + } + exit status + } +' <"$1" diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit new file mode 100755 index 0000000..c24f9bb --- /dev/null +++ b/build-aux/git-hooks/pre-commit @@ -0,0 +1,46 @@ +#!/bin/sh +# Check file names in git commits for GNU Emacs. + +# Copyright 2014 Free Software Foundation, Inc. + +# This file is part of GNU Emacs. + +# GNU Emacs is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# GNU Emacs is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with GNU Emacs. If not, see . + +LC_ALL=C +export LC_ALL + +exec >&2 + +. git-sh-setup + +git_diff='git diff --cached --name-only --diff-filter=A' +ok_chars='\0+[=-=]./0-9A-Z_a-z' +nbadchars=`$git_diff -z HEAD | tr -d "$ok_chars" | wc -c` + +if test "$nbadchars" -ne 0; then + echo "File name does not consist of -+./_ or ASCII letters or digits." + exit 1 +fi + +new_names=`$git_diff HEAD` || exit +case " +$new_names" in + */-* | *' +'-*) + echo "File name component begins with '-'." + exit 1;; +esac + +exec git diff-index --check --cached HEAD -- -- 1.9.3 --------------070701050304010000050400--