From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: git pre-commit hook for merges (WAS: master has switched from Automake to GNU Make) Date: Sat, 29 Apr 2017 11:44:06 -0700 Organization: UCLA Computer Science Department Message-ID: References: <955c464e-5833-10fd-9c02-d7edda70e488@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E81BD35B5FFD1D3D90FE6499" X-Trace: blaine.gmane.org 1493491468 24239 195.159.176.226 (29 Apr 2017 18:44:28 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Apr 2017 18:44:28 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cc: martin rudalics , emacs-devel , Andreas Schwab , Yuri Khan To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 29 20:44:16 2017 Return-path: Envelope-to: ged-emacs-devel@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 1d4XLr-000641-LN for ged-emacs-devel@m.gmane.org; Sat, 29 Apr 2017 20:44:15 +0200 Original-Received: from localhost ([::1]:42000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4XLx-0002QA-Im for ged-emacs-devel@m.gmane.org; Sat, 29 Apr 2017 14:44:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4XLr-0002Pl-2o for emacs-devel@gnu.org; Sat, 29 Apr 2017 14:44:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4XLm-0007nQ-6p for emacs-devel@gnu.org; Sat, 29 Apr 2017 14:44:15 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36358) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d4XLl-0007nD-TW for emacs-devel@gnu.org; Sat, 29 Apr 2017 14:44:10 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D916416009A; Sat, 29 Apr 2017 11:44:07 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id xuMtu0iudqDe; Sat, 29 Apr 2017 11:44:07 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EE5121600A6; Sat, 29 Apr 2017 11:44:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 68_V9Shb6gSw; Sat, 29 Apr 2017 11:44:06 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.153.188.248]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id A2EB316009A; Sat, 29 Apr 2017 11:44:06 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:214419 Archived-At: This is a multi-part message in MIME format. --------------E81BD35B5FFD1D3D90FE6499 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Noam Postavsky wrote: > Since git only runs the hooks on the merged changes when you pass > --no-commit to 'git merge', defaulting to non-blind merge doesn't > really work anyway. Thanks for looking into this. I guess I'll have to rethink how I merge. In the meantime I installed the attached simpler patch, which doesn't bother with an environment variable and simply skips the checks in a two-way merge. --------------E81BD35B5FFD1D3D90FE6499 Content-Type: text/x-diff; name="0001-Allow-bypassing-of-some-checks-when-merging.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Allow-bypassing-of-some-checks-when-merging.patch" >From 8d323317768aaebfc53e01338dd0a9933d1d7de4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 29 Apr 2017 11:28:52 -0700 Subject: [PATCH] Allow bypassing of some checks when merging * build-aux/git-hooks/pre-commit: Don't check merged-in changes. --- build-aux/git-hooks/pre-commit | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit index 6483bfc..548bf93 100755 --- a/build-aux/git-hooks/pre-commit +++ b/build-aux/git-hooks/pre-commit @@ -25,16 +25,32 @@ LC_ALL= . git-sh-setup +# When doing a two-way merge, ignore problems that came from the other +# side of the merge. +head=HEAD +if test -e "$GIT_DIR"/MERGE_HEAD; then + merge_heads=`cat "$GIT_DIR"/MERGE_HEAD` || exit + for merge_head in $merge_heads; do + case $head in + HEAD) head=$merge_head;; + # For multi-head merges, there's no easy way to ignore merged-in + # changes. But if you're doing multi-head merges, presumably + # you know how to handle any ensuing problems. + *) head=HEAD; break;; + esac + done +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` +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 +for new_name in `$git_diff $head`; do case $new_name in -* | */-*) echo "$new_name: File name component begins with '-'." @@ -53,4 +69,4 @@ nbadchars= # tests so that trailing spaces are generated on the fly rather than # being committed as source. -exec git diff-index --check --cached HEAD -- +exec git diff-index --check --cached $head -- -- 2.7.4 --------------E81BD35B5FFD1D3D90FE6499--