From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: Mistakes in commit log messages Date: Tue, 11 Apr 2023 12:27:40 -0700 Message-ID: References: <835ya5m4p0.fsf@gnu.org> <83v8i4arzt.fsf@gnu.org> <838rezardu.fsf@gnu.org> <319d616d-9230-0a82-331f-0f57488e4c80@gmail.com> <834jpm9s1g.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38002"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Apr 11 21:28:47 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmJfZ-0009g2-Ff for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Apr 2023 21:28:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmJee-0002a9-E6; Tue, 11 Apr 2023 15:27:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmJed-0002Zd-FZ for emacs-devel@gnu.org; Tue, 11 Apr 2023 15:27:47 -0400 Original-Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmJea-0005co-VR; Tue, 11 Apr 2023 15:27:47 -0400 Original-Received: by mail-pj1-x1030.google.com with SMTP id v9so14342336pjk.0; Tue, 11 Apr 2023 12:27:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681241262; x=1683833262; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=vEk8r3ygTmzq//r3AsXisZLTg7Uu0hUxYslWD6DvNGI=; b=qMSbuqCQ5pUtM6pK0EIjosdT6ivRDNzr0ERdIPWEtChzuRcJ935rCXIndqNAV51vnl H0A41+eQwpWzxXcfPVDrwY3klVYIHVIWyaqHK+Vi8leZPuyzOsPyCATPxsyNceVdIjZ/ c/J7/in3pw7UZlyoxI8qGabcjl9iArSDab+XeUXxU80/SXJ2JfJ7nbNIjwLfG3K2ySqL oYLt/yo9xUin15VLV9v9nEHihOFkaRg0MpLCanVfgnALowW+kwBBTyLrggAJU/PweOAI PMgQKyuCP1ZgZZWlo8VDVaTIOWs2e1ZTfbN+mHBkI310LTtrr91qrEiANAMvgS7CnAkx NuXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681241262; x=1683833262; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vEk8r3ygTmzq//r3AsXisZLTg7Uu0hUxYslWD6DvNGI=; b=bzlj5f4nY1FUW68k03a750Ej7XxdNVsvpn2ITpffWwvt5ULK9YfxWGfmyz757AD8Vc 8oCWbBtPXyNRooKYUidW38EvghN+Z3g7cQ2CXuLfmeL1XzeDZeiU2YpeCqaRCliUGUEz ZTVJU6uo2nKDXRhBmV8bmRe/OrgzVDc8MH8Q2LuXgRezlBjfdCz8XHafX2IP6OmbdWgJ pxCvsYhZpW0olmg9QN7PUSm1RGo4aRpYRtcdIITZspsMIOsX2s57w4qzCjulryfshs6O XkfWQKqTKNlEaZXDw0+UnTTqE4mrO86tWuU/NljD4EMShFCKNnwixkx5mFXIqSnnnu4S 2ppQ== X-Gm-Message-State: AAQBX9ci3JTGBxsQ7wPZ3h2QP/XvdqZMNgwicG2bRXxdNDfvNqK0HHEP TlwWfN1T5FTGKAKQ4NhoRz6mLtlku80W6g== X-Google-Smtp-Source: AKy350ZKgWOKhzdq5wLW4oLbhwz2+luCSM7N1Do7+xLWnkw/Qh11IWsCe0XaDxZBjx/eteKegcbxYg== X-Received: by 2002:a17:902:ec8a:b0:1a1:ee8c:eef7 with SMTP id x10-20020a170902ec8a00b001a1ee8ceef7mr22909781plg.48.1681241262393; Tue, 11 Apr 2023 12:27:42 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id p18-20020a1709028a9200b001a240f053aasm6526230plo.180.2023.04.11.12.27.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 12:27:41 -0700 (PDT) Content-Language: en-US In-Reply-To: <834jpm9s1g.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305249 Archived-At: On 4/11/2023 11:45 AM, Eli Zaretskii wrote: >> Date: Tue, 11 Apr 2023 11:31:55 -0700 >> Cc: emacs-devel@gnu.org >> From: Jim Porter >> >> Finally, I think it would make sense to have this be a purely advisory >> warning for now so that we could check it into the Emacs tree soon-ish. > > How will this help, given that some people use Magit to commit and > some use VC, not the Git commands from the shell? Are we sure the > warnings will be seen, let alone acted upon? I don't know. If VC and Magit don't show messages from Git hooks, they probably should. Those messages are there for a reason, after all. However, warnings that only some users see would hopefully still help us get feedback on whether the validation works properly. Some miscellaneous thoughts on this: One issue with the current implementation (mentioned elsewhere in this thread) is that it doesn't work for deleting a file from the repo. Fixing this in the commit-msg hook is tricky. We can get the list of changed files via "git diff --name-only" (and then we could compare our commit message against that list), but there's a problem: I don't know of a good way to detect when the user is amending a commit[1]. For a normal commit, you'd get the changed files via something like "git diff --staged --name-only", but for an amended commit, you'd want to add "HEAD^" to that command. Another option might be to do this as a pre-push hook. By then, the commits are finalized, so we can more easily compare the commit message and its diff. This is also nice because when the commit-msg hook errors out, it throws away the commit message; quite annoying if you just made a small typo! However, it does mean that committers would need to be comfortable with amending their commit messages if they hit this error. (We could also check this in a post-commit hook so that committers are alerted *before* they try to push, but post-commit hooks can't abort the commit: it's already done! Maybe we could have a post-commit hook that warns the committer, and a pre-push hook that actually errors out.) [1] The only way I've seen to do this is to look at the arguments from the parent (Git) process that called the hook: . I'm not sure how reliably that works, especially on platforms like MS-Windows...