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: New Git hooks for checking file names in commit messages Date: Fri, 21 Apr 2023 09:39:57 -0700 Message-ID: <487901f5-bb88-cecd-cc72-e2b42cff4cf8@gmail.com> References: 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="32738"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 21 18:40:50 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 1pptoY-0008PH-Gn for ged-emacs-devel@m.gmane-mx.org; Fri, 21 Apr 2023 18:40:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pptnm-0002O9-6g; Fri, 21 Apr 2023 12:40:02 -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 1pptnk-0002NF-8o for emacs-devel@gnu.org; Fri, 21 Apr 2023 12:40:00 -0400 Original-Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pptni-0002ab-Ep for emacs-devel@gnu.org; Fri, 21 Apr 2023 12:39:59 -0400 Original-Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-51b661097bfso1862868a12.0 for ; Fri, 21 Apr 2023 09:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682095198; x=1684687198; 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=XJKMN6fDcZh60PCKzhH30htJWxBR3+LZjis9jlIlNnw=; b=M++JOYiADZtxlDJAeNG79Khu6otjQRbi6XqDb+ATxQI2+gwe0QafF1jcRXLl63F7Ln SL8UeMCvitANCyU8WEur86rjJxX4/xPlTqIhylVO7A9pgtVTMXlNbHPDLlMUAklQuypi Mv+/hmlMNNJjcOnYMvwa6wzBC34wf9TECXXU2HOI5fwxjLV34qJFHYTs+GeZmc8PN3fw U6StZBZtj1VN3kLaBQ+3y6NIJ1cAbRyPwq+X+Ne8gPzTpQiqbNzf1waae1kgTLxJZ6LQ T8r1zWx7UU0L4FL8G/nVorhdk25J5Rjn7OrSqLHGJjP3NhTMcm7RR6bVTor0gLigrHY5 qW/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682095198; x=1684687198; 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=XJKMN6fDcZh60PCKzhH30htJWxBR3+LZjis9jlIlNnw=; b=JgTwa7Ow0ooga6eafVGNTNHjmsL3yC9YjsmJO/UTLgTj1ZBdY4C4W3SmXQWAGQFsKj gNnWZ0MZLBYdErZBIhAK48PKZEBEKCjdyakj9FIFr7qYXXcJjbbVQW/NW+SozdkWBfOq 0QsJXFiheKC9UrpRYFjrl/TzSfy5M2o9EbliMqlVkAVvWl97vgoW/pBYOJzd8ScRx/iw mPo1ePVjcAOGOxAHIUtSuK2ARifhbA6/AjpIFzm4DSldB0LcjgilY437y5St6E6/yQev ycUWZSy2m2cwHiEJcCYFduCFjqrwVBmSoRz/Pj1gqZU2O248mAkZp/48SCVV8FvAKtrK vlJA== X-Gm-Message-State: AAQBX9cgUjL2VKsIENdAJP821aYp5IR1gJL0N5/MGUdxYqc7lxoKXKb2 mI+WBOiIHRoOMUOB5VcpXGHhOH02sTTGxw== X-Google-Smtp-Source: AKy350bhmvmNmcnu2JGaRO0/spAdtuN4jejrqL0v2WsRFw5hXI2Nx5rxOiT7fwRNXvu+xgH7fNLhSg== X-Received: by 2002:a17:90a:fa97:b0:246:634d:a89c with SMTP id cu23-20020a17090afa9700b00246634da89cmr5553204pjb.41.1682095197656; Fri, 21 Apr 2023 09:39:57 -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 y18-20020a17090aa41200b00244991b3f7asm5518359pjp.1.2023.04.21.09.39.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Apr 2023 09:39:57 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=jporterbugs@gmail.com; helo=mail-pg1-x536.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, T_SCC_BODY_TEXT_LINE=-0.01 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:305555 Archived-At: On 4/21/2023 6:57 AM, Alan Mackenzie wrote: > How is this helpful? Telling somebody they've made a mistake is only > helpful if they can correct it. If "it's too late to error out", it > will just create annoyance. Immediately after such a commit it is > possible to use $ git commit --amend, but not later. This is why I added a post-commit hook that informs the committer of the problem immediately after committing. However, since this is a *post*-commit hook, it's too late to abort the commit. So there is a message, but it's purely advisory at that stage. Sorry if my wording was unclear originally. >> [1] It's hard to do this during the commit-msg hook since there's no >> cross-platform way I know of to handle amending commits properly. > > I don't understand this bit. Why does the lack of a way of amending > commits make it difficult to error out from the commit-msg hook? What > am I missing? It's impossible (as far as I'm aware) to reliably get a list of changed files from Git during the commit-msg hook. Since you can't tell whether the commit is being amended without platform-specific hacks, you have no way of knowing whether you should compute your diff against HEAD or HEAD^.