GNU bug report logs -
#64055
31.0.50; log-view-modify-change-comment support for Git and Hg
Previous Next
Full log
View this message in rfc822 format
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
This bug report was last modified 104 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.