From: Sean Whitton <spwhitton@spwhitton.name>
To: Morgan Smith <Morgan.J.Smith@outlook.com>,
64055@debbugs.gnu.org, Dmitry Gutov <dgutov@yandex.ru>,
Robert Pluim <rpluim@gmail.com>
Subject: bug#64055: [WIP Patch] Enable editing commit messages - vc-git-modify-change-comment
Date: Thu, 10 Oct 2024 10:45:27 +0800 [thread overview]
Message-ID: <871q0obrqw.fsf@melete.silentflame.com> (raw)
In-Reply-To: <DM5PR03MB3163ADD665E6B3B1D8704A2AC555A@DM5PR03MB3163.namprd03.prod.outlook.com> (Morgan Smith's message of "Tue, 13 Jun 2023 18:59:24 -0400")
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
next prev parent reply other threads:[~2024-10-10 2:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 22:59 bug#64055: [WIP Patch] Enable editing commit messages - vc-git-modify-change-comment Morgan Smith
2023-06-14 8:00 ` Robert Pluim
2023-06-14 11:41 ` Morgan Smith
2023-06-14 13:13 ` Robert Pluim
2023-06-14 13:54 ` Morgan Smith
2023-06-14 15:30 ` Robert Pluim
2024-10-01 2:38 ` Sean Whitton
2024-10-01 19:32 ` Dmitry Gutov
2024-10-02 0:01 ` Sean Whitton
2024-10-02 23:20 ` Dmitry Gutov
2024-10-10 2:39 ` Sean Whitton
2024-10-10 2:48 ` Sean Whitton
2024-10-17 13:27 ` Sean Whitton
2024-10-18 5:26 ` Eli Zaretskii
2024-10-18 6:20 ` Sean Whitton
2024-10-18 9:14 ` Eli Zaretskii
2024-10-18 9:30 ` Sean Whitton
2024-10-18 12:18 ` Eli Zaretskii
2024-10-18 0:46 ` Dmitry Gutov
2024-10-18 4:50 ` Sean Whitton
2023-06-17 2:40 ` Dmitry Gutov
2024-10-01 2:37 ` Sean Whitton
2024-10-01 13:35 ` Dmitry Gutov
2024-10-10 2:45 ` Sean Whitton [this message]
2024-10-10 6:12 ` Eli Zaretskii
2024-10-10 6:23 ` Sean Whitton
2024-10-10 7:36 ` Eli Zaretskii
2024-10-10 7:46 ` Sean Whitton
2024-10-18 9:26 ` bug#64055: Implementation of modifying VC change comments for Git Sean Whitton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q0obrqw.fsf@melete.silentflame.com \
--to=spwhitton@spwhitton.name \
--cc=64055@debbugs.gnu.org \
--cc=Morgan.J.Smith@outlook.com \
--cc=dgutov@yandex.ru \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.