Pre-fill the log-edit buffer for reverts and cherry-picks.
* magit.el (magit-append-to-log-edit, magit-escape-for-shell, magit-format-commit): New. (magit-apply-item, magit-revert-item): Use them.
This commit is contained in:
parent
226ad5a956
commit
45bff9c642
1 changed files with 18 additions and 0 deletions
18
magit.el
18
magit.el
|
@ -1019,16 +1019,34 @@ Please see the manual for a complete description of Magit.
|
|||
(or commit
|
||||
(error "No commit at point.")))))
|
||||
|
||||
(defun magit-append-to-log-edit (str)
|
||||
(save-excursion
|
||||
(set-buffer (get-buffer-create "*magit-log-edit*"))
|
||||
(goto-char (point-max))
|
||||
(insert str "\n")))
|
||||
|
||||
(defun magit-escape-for-shell (str)
|
||||
(concat "'" (replace-regexp-in-string "'" "'\\''" str) "'"))
|
||||
|
||||
(defun magit-format-commit (commit format)
|
||||
(magit-shell "git log --max-count=1 --pretty=format:%s %s"
|
||||
(magit-escape-for-shell format)
|
||||
commit))
|
||||
|
||||
(defun magit-apply-item ()
|
||||
(interactive)
|
||||
(magit-item-case (item info "apply")
|
||||
((commit)
|
||||
(magit-append-to-log-edit
|
||||
(magit-format-commit info "%s%n%n%b%n(Cherrypicked from %H)"))
|
||||
(magit-run "git" "cherry-pick" "--no-commit" info))))
|
||||
|
||||
(defun magit-revert-item ()
|
||||
(interactive)
|
||||
(magit-item-case (item info "revert")
|
||||
((commit)
|
||||
(magit-append-to-log-edit
|
||||
(magit-format-commit info "Reverting %h, %s"))
|
||||
(magit-run "git" "revert" "--no-commit" info))))
|
||||
|
||||
(defvar magit-currently-shown-commit nil)
|
||||
|
|
Loading…
Reference in a new issue