From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#29197: 27.0.50; pre-commit checks for new files against "head" Date: Wed, 14 Feb 2018 20:03:50 -0500 Message-ID: <87lgfv83nt.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1518656608 8631 195.159.176.226 (15 Feb 2018 01:03:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Feb 2018 01:03:28 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) To: Stefan Monnier , 29197@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 15 02:03:23 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1em7x7-00013V-N5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Feb 2018 02:03:09 +0100 Original-Received: from localhost ([::1]:50487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1em7z7-0005Fc-SX for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Feb 2018 20:05:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1em7z0-0005Eb-OR for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2018 20:05:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1em7yw-0007XC-P1 for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2018 20:05:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35576) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1em7yw-0007X4-GD for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2018 20:05:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1em7yw-0007Yp-4B for bug-gnu-emacs@gnu.org; Wed, 14 Feb 2018 20:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Feb 2018 01:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29197 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29197-submit@debbugs.gnu.org id=B29197.151865664228977 (code B ref 29197); Thu, 15 Feb 2018 01:05:02 +0000 Original-Received: (at 29197) by debbugs.gnu.org; 15 Feb 2018 01:04:02 +0000 Original-Received: from localhost ([127.0.0.1]:43473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1em7xx-0007XC-1n for submit@debbugs.gnu.org; Wed, 14 Feb 2018 20:04:01 -0500 Original-Received: from mail-io0-f173.google.com ([209.85.223.173]:45474) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1em7xu-0007Ww-Rf for 29197@debbugs.gnu.org; Wed, 14 Feb 2018 20:03:59 -0500 Original-Received: by mail-io0-f173.google.com with SMTP id p188so27160098ioe.12 for <29197@debbugs.gnu.org>; Wed, 14 Feb 2018 17:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=1tqokSR67u6r4DWjRfsnHWQVCEus928lKUakDeTH1mw=; b=kW7Urrk6Eb6RR+zdCZx//d9LErHGiNpiBITInjnV3FBhaAgtsD/3Oug0YWhf6vJfj9 vKCHL0vaRJf7sayuF6tjWBmD4iQ6OQswGPHsA1D6aSparpODzJpC0Uhvt8drgZ8p0k8Z 0LdRjXMQk2G/HDxA5w6cyG1AE1l6fLRorMfacnlLE5b4romPsB2bo1XEHon/ZA/6NoJo 0HZY4gcwT1o411zyc065XOcl4mvFSP6EGmr6u1cH1JFhpQN7xCCdKKol438L1IKLbPxc J3qYgMDT8fVCMLhshPrHpmhfXQOIJ5Dm15XmnX2BuDGf04uiEhs6kwYxuAyB+HS547nr p0RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=1tqokSR67u6r4DWjRfsnHWQVCEus928lKUakDeTH1mw=; b=hnF/VqirC2sl7r6+erap55YMaQE5l02qTdGJHPKS28HsdE7OKZ80BgKOxiTwoAP1z6 a98ofOcFqQsA1gffnYN+FY9tAWbP8yAx0vF6Isjm3wql9jGItBNDpnUtj1PMmhF0Yknp UtRRjf1OfAzHYF/JblzTlEgzyMBLUPWL11QUBHIAh/fIzvLTKCtiQKC/xFbVF8iSfAzB 70Ly9pCm++wPpCmm/1ENHyfCoCkbtDnbDIF+3dlh7hnXt5ZLrOj6VgKVxqASMBzIduVA rj2W3Fu6bVAIeYRnQ+tWWySpa2mMCH0rkSgnr1v8KEFpdNTlM4gjTpZCGcBwO7qLZnyF UYIQ== X-Gm-Message-State: APf1xPBXssmQFrGtUlvPXTo2tdZFCX5lNPpVNKC2vxg0j4c2CLxY6txf onXGlLX9w2CVlaasSpYXqaWmbg== X-Google-Smtp-Source: AH8x226LW2K7BvnDet+nT+eUiR8QVdONGYSpl7Gsd1U3hPZPgoI/1ZZVUNxHnblYe0k4tD4uTcnB2g== X-Received: by 10.107.148.139 with SMTP id w133mr1453310iod.175.1518656633016; Wed, 14 Feb 2018 17:03:53 -0800 (PST) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 91sm26952ioh.59.2018.02.14.17.03.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 17:03:51 -0800 (PST) In-Reply-To: (Noam Postavsky's message of "Tue, 7 Nov 2017 16:36:37 -0500") 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: 208.118.235.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:143295 Archived-At: --=-=-= Content-Type: text/plain Noam Postavsky writes: >> I think the warning should be improved: >> - I shouldn't get a warning in the above case, since this commit doesn't >> *add* those files (they weren't on origin/master admittedly but they were >> already on HEAD). > > We could choose which side of the merge to check based on an > environment var (that was considered in the thread I referenced above, > but we didn't see much of a use case at the time). Or is it possible > to check only changes from the merge itself (i.e., in case of conflict > resolution)? > >> - the warning should give me some hint about which file fails the test. > > Yeah, that would make sense. This seems fairly difficult to do while keeping in standard bourne shell syntax. Not sure how to catch file names with whitespace. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Let-pre-commit-git-hook-check-merged-in-changes-B.patch Content-Description: patch >From fa94e7452be5ffb4d63ad2a40fc5b9fdeed3fed0 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 14 Feb 2018 19:58:07 -0500 Subject: [PATCH v1] ; Let pre-commit git hook check merged in changes (Bug#29197) * build-aux/git-hooks/pre-commit: If GIT_MERGE_CHECK_OTHER is 'true', check changes against the merge target, rather than the current branch. Include file name when giving error message about non-standard characters. --- build-aux/git-hooks/pre-commit | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit index 5e42dab233..33d8c91168 100755 --- a/build-aux/git-hooks/pre-commit +++ b/build-aux/git-hooks/pre-commit @@ -28,7 +28,7 @@ LC_ALL= # When doing a two-way merge, ignore problems that came from the other # side of the merge. head=HEAD -if test -r "$GIT_DIR"/MERGE_HEAD; then +if test -r "$GIT_DIR"/MERGE_HEAD && test "$GIT_MERGE_CHECK_OTHER" != true; then merge_heads=`cat "$GIT_DIR"/MERGE_HEAD` || exit for merge_head in $merge_heads; do case $head in @@ -42,13 +42,6 @@ head= fi 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 for new_name in `$git_diff $head`; do case $new_name in @@ -58,9 +51,20 @@ nbadchars= ChangeLog | */ChangeLog) echo "$new_name: Please use git commit messages, not ChangeLog files." exit 1;; + *[^-+./_0-9A-Z_a-z]*) + echo "$new_name: File name does not consist of -+./_ or ASCII letters or digits." + exit 1;; esac done +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 "A file name has whitespace." + exit 1 +fi + # The '--check' option of git diff-index makes Git complain if changes # introduce whitespace errors. This can be a pain when editing test # files that deliberately contain lines with trailing whitespace. -- 2.11.0 --=-=-=--