From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#64055: [WIP Patch] Enable editing commit messages - vc-git-modify-change-comment Date: Thu, 10 Oct 2024 10:45:27 +0800 Message-ID: <871q0obrqw.fsf@melete.silentflame.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: Morgan Smith , 64055@debbugs.gnu.org, Dmitry Gutov , Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 10 04:46:19 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1syjBy-0004Vo-HM for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Oct 2024 04:46:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syjBZ-0004U0-Gt; Wed, 09 Oct 2024 22:45:53 -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 1syjBY-0004Tl-8q for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 22:45:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1syjBX-00037K-Kz for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 22:45:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=WHV0rkoB5TOEpUZbgHZU0DMTmg96bDGSx9hX7MOL88E=; b=k+XvIG6BjEalJLCwn1IiABL5JT7wQL5x7k0dVVi4G9eDSxdqg1P6jzGT3l8AnERWEzJ2nME0fd4gQoezl1ivM9skl86CQZ5M4geeWIsUzVOHN4nGvt7Jr2ijR/KRX9SZfwG56vTe2zVFxMimOmrFS7zRK2nfuJUaQ8l9SP382TgjsyrVAjTLF9xQ9EticAcnWl8JAkYSRGuHW+MTDd6uPphc1DRCVLzt/Lo+rF16Wo1eVtOcZatTEkRsTcTihZN54uSOp6URQ5HWien8ioPHWbAi/bfpKnS9H3Wc7KO63nWeXsSI6QmxT3mojRqY/aOXxzIguEOc/4UTn+5kO63dLQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1syjBi-0001UT-BH for bug-gnu-emacs@gnu.org; Wed, 09 Oct 2024 22:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Oct 2024 02:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64055 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64055-submit@debbugs.gnu.org id=B64055.17285283605719 (code B ref 64055); Thu, 10 Oct 2024 02:46:02 +0000 Original-Received: (at 64055) by debbugs.gnu.org; 10 Oct 2024 02:46:00 +0000 Original-Received: from localhost ([127.0.0.1]:58173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1syjBf-0001UB-HQ for submit@debbugs.gnu.org; Wed, 09 Oct 2024 22:45:59 -0400 Original-Received: from sendmail.purelymail.com ([34.202.193.197]:35524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1syjBd-0001Tv-Fh for 64055@debbugs.gnu.org; Wed, 09 Oct 2024 22:45:58 -0400 DKIM-Signature: a=rsa-sha256; b=e9obipm1vaiwTdwF8/KrlZHVFiqjWN2mjRlWzf2ZtGNU/F9/3vmKtW1io7kxUi124jcbUyAjCVnYnj3zMlQ5rGw2eA3xhnDbRKh6Apwj9Ldd6H87W8zs+VS2yYMcj4gshw6nNA/5tvTufiiZz64d8087IbDLZpC/uPe9+Qu6Jbun3+7oPOf5/vEiH/4M8U35VCwfCAX4Cwi8UlhLPVFJavFqQRnI2fgn3xG/L5XLBV3843mq2+sgir9Toz+xale/gSRcf2AArrujaAvcmYAEAhbpkfEqko7I1S1AgENwk3xu7EPhqcHnX8pgQIyNlrA31qzPSuEHdWe4V4LMXjJ4FQ==; s=purelymail3; d=spwhitton.name; v=1; bh=RnStifhSGYRpG7X7uTMzczvUuqJHXqQ+Zk2mU6EgA3I=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=T2A8NxhBreOshV/hc98ls+MRz1vdXPVUfGMH9TZNrBnOCfkDQ8y07pG3eox5nEfu2wI37FErKDN5rT2rYbKii1KaYqYPGGg8z1lRJslxTOgTx27H6m3wNKCVs7V3ONCtzC7NRn5qXB2Y3EkeNdnMAqMaFxrQZrR1T61JYwKZOq0B97mSxR+3DoU+zCL7Qg0xNZCwLV8feqKhF7/6t0MsiOaj846eUj63xrTIYxpoJoxxCgba6r/l6l8CVG0naX4KGz1q/p0QuFvVkdRlncXe9tnPu7v1wsSr5uqudL3+j/L5t9pUYKrLMGXftl5M6cGVDySxwLWrlfFekdu8SNb+Zw==; s=purelymail3; d=purelymail.com; v=1; bh=RnStifhSGYRpG7X7uTMzczvUuqJHXqQ+Zk2mU6EgA3I=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 64055@debbugs.gnu.org Original-Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1884983643; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 10 Oct 2024 02:45:32 +0000 (UTC) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id D2B8F7E7EB4; Thu, 10 Oct 2024 10:45:27 +0800 (CST) In-Reply-To: (Morgan Smith's message of "Tue, 13 Jun 2023 18:59:24 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293239 Archived-At: Hello, On Tue 13 Jun 2023 at 06:59pm -04, Morgan Smith wrote: > diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el > index a3469b71386..18d6f1f47dc 100644 > --- a/lisp/vc/vc-git.el > +++ b/lisp/vc/vc-git.el > @@ -1384,6 +1384,24 @@ vc-git-clone > (vc-git--out-ok "clone" remote directory)) > directory) > > +(defun vc-git-modify-change-comment (_files rev comment) > + "Modify the change comments on REV to COMMENT." > + ;; This is very similar to using to "git commit --fixup=amend" > + ;; command but it is more precise as it does the rebase matching > + ;; with the hash instead of the subject line. Also we can't use > + ;; --fixup non-interactively (it doesn't support -m or -F) so this > + ;; is much easier. > + (vc-git-command nil 0 nil "commit" > + "--allow-empty" > + "-m" (concat "amend! " rev "\n\n" comment)) > + ;; We should really be able to do this "non-interactively" but we > + ;; can't so we set GIT_SEQUENCE_EDITOR > + (let ((process-environment > + (cons > + "GIT_SEQUENCE_EDITOR=:" > + process-environment))) > + (vc-git-command nil 0 nil "rebase" "--autosquash" "-i" (concat rev "~1")))) > + > ;;; HISTORY FUNCTIONS A few notes here: - We will need to ensure that the commit is actually empty, not just allow it to be empty. We have vc-git--stash-staged-changes we could use, but on my machine git-commit has --fixup=reword:... which is for amending only the commit message. So probably use that. - We will probably want to pass --autostash to git-rebase, too. - It is probably best to set GIT_SEQUENCE_EDITOR=true so that we're not relying on the shell -- there is no /bin/:, but there is /bin/true. This is minor. > @@ -1576,7 +1594,13 @@ vc-git-expanded-log-entry > (apply #'vc-git-command t nil nil > `("log" > ,revision > - "-1" "--no-color" ,@(ensure-list vc-git-log-switches) > + "-1" "--no-color" > + ;; The same as the default "medium" format but it doesn't > + ;; put spaces at the beginning of the body. This is so > + ;; we can grab this as the initial value when calling > + ;; log-view-modify-change-comment > + "--pretty=format:commit %H%nAuthor: %an %ae%nDate: %ad%n%n%B" > + ,@(ensure-list vc-git-log-switches) > "--")) > (goto-char (point-min)) > (unless (eobp) I think it's preferable to use a vc-git--extract-comment as in the patch I just posted. -- Sean Whitton