From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#35368: [PATCH v3] Do potentially destructive operations in prepare-commit-msg Date: Wed, 15 May 2019 01:26:47 +0300 Message-ID: <20190514222647.4799-1-Hi-Angel@yandex.ru> References: <87k1esg02j.fsf@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="108662"; mail-complaints-to="usenet@blaine.gmane.org" To: 35368@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 15 00:28:30 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQfuP-000S3C-MB for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 May 2019 00:28:29 +0200 Original-Received: from localhost ([127.0.0.1]:55928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQfuO-0004KN-MV for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 18:28:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQfu0-0004Bg-FT for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 18:28:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQftz-000760-54 for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 18:28:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQfty-00075X-Gt for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 18:28:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hQfty-0001JR-7y for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 18:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 May 2019 22:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35368 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35368-submit@debbugs.gnu.org id=B35368.15578728264973 (code B ref 35368); Tue, 14 May 2019 22:28:02 +0000 Original-Received: (at 35368) by debbugs.gnu.org; 14 May 2019 22:27:06 +0000 Original-Received: from localhost ([127.0.0.1]:50201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQft4-0001I8-FG for submit@debbugs.gnu.org; Tue, 14 May 2019 18:27:06 -0400 Original-Received: from forward105p.mail.yandex.net ([77.88.28.108]:57046) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQft0-0001HN-5B for 35368@debbugs.gnu.org; Tue, 14 May 2019 18:27:03 -0400 Original-Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 1221D4D41BB1 for <35368@debbugs.gnu.org>; Wed, 15 May 2019 01:26:55 +0300 (MSK) Original-Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PZk4xNdvSu-QsRKXABh; Wed, 15 May 2019 01:26:55 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1557872815; bh=8Xe31Ow7qTrBSaB+KP8bx99URhVuChzN7ebVNiMLjxs=; h=In-Reply-To:Subject:To:From:References:Date:Message-Id; b=lZlu2S7AIk3L6Id+75DBjWa0Svy7nGiXZWmQu68fLLx6otLKYj3PzkogA0mi8CkRO wUmmIws127q/ZjRcBJll+o/pVkjRqs3zHtITxVLboAxbHLKxhjJOubyaG5s+Vr64me 5sIBxaR0SRJak2VayqiRJZ2KiwMMYY/zrlS1k6ZU= Authentication-Results: mxback8j.mail.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZCX6XjFeg8-Qsva5DbP; Wed, 15 May 2019 01:26:54 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Mailer: git-send-email 2.21.0 In-Reply-To: <87k1esg02j.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159299 Archived-At: * build-aux/git-hooks/prepare-commit-msg: if someone occasionally puts Signed-off line, it will likely get there through -s option of git. Exploit this fact to abort before a user got a chance to type commit message. --- v3: remove unused at_sign, cent_sign, and COMMIT_MSG_FILE awk variables autogen.sh | 4 +-- build-aux/git-hooks/prepare-commit-msg | 43 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100755 build-aux/git-hooks/prepare-commit-msg diff --git a/autogen.sh b/autogen.sh index 40d0c37b11b..a0a2ac3c689 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/sh + #!/bin/sh ### autogen.sh - tool to help build Emacs from a repository checkout ## Copyright (C) 2011-2019 Free Software Foundation, Inc. @@ -332,7 +332,7 @@ hooks= tailored_hooks= sample_hooks= -for hook in commit-msg pre-commit; do +for hook in commit-msg pre-commit prepare-commit-msg; do cmp -- build-aux/git-hooks/$hook "$hooks/$hook" >/dev/null 2>&1 || tailored_hooks="$tailored_hooks $hook" done diff --git a/build-aux/git-hooks/prepare-commit-msg b/build-aux/git-hooks/prepare-commit-msg new file mode 100755 index 00000000000..961ddf38486 --- /dev/null +++ b/build-aux/git-hooks/prepare-commit-msg @@ -0,0 +1,43 @@ +#!/bin/sh +# Check the format of GNU Emacs change log entries. + +# Copyright 2019 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 . + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +# Prefer gawk if available, as it handles NUL bytes properly. +if type gawk >/dev/null 2>&1; then + awk=gawk +else + awk=awk +fi + +exec $awk ' + /^Signed-off-by: / { + print "'\''Signed-off-by:'\'' in commit message" + status = 1 + } + END { + if (status != 0) { + print "Commit aborted; please see the file 'CONTRIBUTE'" + } + exit status + } +' <"$COMMIT_MSG_FILE" -- 2.21.0