From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: git pre-commit hook for merges (WAS: master has switched from Automake to GNU Make) Date: Tue, 11 Apr 2017 12:25:36 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1491927992 21329 195.159.176.226 (11 Apr 2017 16:26:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Apr 2017 16:26:32 +0000 (UTC) Cc: martin rudalics , Paul Eggert , emacs-devel , Andreas Schwab To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 11 18:26:27 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 1cxycd-0005Rm-BM for ged-emacs-devel@m.gmane.org; Tue, 11 Apr 2017 18:26:27 +0200 Original-Received: from localhost ([::1]:40191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxycj-0003ZF-4W for ged-emacs-devel@m.gmane.org; Tue, 11 Apr 2017 12:26:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxybr-0003SE-88 for emacs-devel@gnu.org; Tue, 11 Apr 2017 12:25:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxybq-0001kA-0p for emacs-devel@gnu.org; Tue, 11 Apr 2017 12:25:39 -0400 Original-Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:33574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxybp-0001k2-Ok for emacs-devel@gnu.org; Tue, 11 Apr 2017 12:25:37 -0400 Original-Received: by mail-oi0-x231.google.com with SMTP id b187so2892964oif.0 for ; Tue, 11 Apr 2017 09:25:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=EoTNAdo8cOGVvT6pm8YvJcoD3T82dvftdIZKb39hWEQ=; b=nhTPd867aZWzStrsUXiAQny3viDyEMJ9QYssgmrS3QpQxhfl80Hv3Ym5OvncxEbeNy ms4w+NUlLqclAkJxyYCaUJbHsWSK+DWLAskd2zgqzffDgGQozc9jvA3IndpD/Od41Rv0 rZX1UJ5Wu/JZ/dGPlqGZ+5cbm1fEMt1R3r2pfOzeGGPiNhnYo/xSYC/1WeNAEnHgc725 Yft7yPjUpChckaY7Aof6H1kcDBq+elS1XTBNMngUYAkFVKWsnnlaBCDMXu5kFVcXVcb1 H5mJezFr+OIpLcSAuJampDELxvvWl8qVg4RCbL1k18FWuFDrEJMDvQLZf5aXNNxustCl lHWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:cc:content-transfer-encoding; bh=EoTNAdo8cOGVvT6pm8YvJcoD3T82dvftdIZKb39hWEQ=; b=J5l5AVzMnnLSf/KSMhs/8tc1tH3uQgslNQjAoGBOKq/H0T+NI3+Zn2l0/E4tOsJnrW DGkH2z7H49xReoUEZRLThmQAydfOCCDEOmhYhN0qGDIY8vXtgBQJ69BcWg5j/41+t4Mf FRVvleiFMoRsTlwpmIwWyHQH6wpcy1w6yNvHYRZUOuoRu/2GJrcYVXc+vSKdDcSBbfa8 gY2dg5KiBOyZSfG/i1EVqjx2fdOv1vVhVgPwpu+BG3/Clj41USC6CST+sE4is//vuRM7 cZSRerq6Bv1zf8tY2YomAN/Xo/3vZNQSI83RjnbWLFM0G8MpEaSUpCEx0Rh2QbURr2K8 ZULA== X-Gm-Message-State: AN3rC/53lGUngDg+VX57PBEM1U2A+Ehj0hpb6Q2IA58E4qYE17AsbsTOj63Ihoa+U4GHCPi6LVsRjRcTgFcQCQ== X-Received: by 10.157.54.194 with SMTP id s2mr4479274otd.267.1491927937092; Tue, 11 Apr 2017 09:25:37 -0700 (PDT) Original-Received: by 10.157.80.133 with HTTP; Tue, 11 Apr 2017 09:25:36 -0700 (PDT) X-Google-Sender-Auth: osfBuVsuEMI3WR1UtmqnVHRIVek X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::231 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:213872 Archived-At: On Tue, Apr 11, 2017 at 11:13 AM, Yuri Khan wrote: >> I always want a merge. So what do you recommend? In particular what do >> you recommend when there are conflicts? IIUC in that case git does not >> merge anything but waits till I have resolved the conflicts and tells me >> to commit them when I'm done. If, at that moment, I do commit I'm in >> the same situation with SpecialCasing.txt as before. Or is there any >> difference? > > Well, I would recommend rebasing, which would solve the > SpecialCasing.txt problem because your rebased branch would start > after the problematic file has been committed. > > But if you insist on merging, it=E2=80=99s doable, too. Then I guess you > get a merge conflict, > resolve it, > stage the resolved files, > attempt to commit, > get a whitespace policy violation, > say an expletive of your choice, > see that the violation was not your doing, > optionally confirm that by looking at the history of the problematic > file in the branch you=E2=80=99re merging, > then say =E2=80=9COh well=E2=80=9D and commit bypassing the check. Perhaps we should change the hook so that it doesn't complain about problems from merges? --- i/build-aux/git-hooks/pre-commit +++ w/build-aux/git-hooks/pre-commit @@ -25,16 +25,23 @@ LC_ALL=3D . git-sh-setup +# If we're merging, don't flag problems that came from the other side +# of the merge. +head=3DHEAD +if [ -f "$GIT_DIR"/MERGE_HEAD ] ; then + head=3D$(cat "$GIT_DIR"/MERGE_HEAD) +fi + git_diff=3D'git diff --cached --name-only --diff-filter=3DA' ok_chars=3D'\0+[=3D-=3D]./0-9A-Z_a-z' -nbadchars=3D`$git_diff -z HEAD | tr -d "$ok_chars" | wc -c` +nbadchars=3D`$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 +60,4 @@ nbadchars=3D # 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" --