From 45bff9c64223e9398808ea18293d2a739d2a91eb Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 30 Aug 2008 21:15:02 +0300 Subject: [PATCH] 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. --- magit.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/magit.el b/magit.el index dd477bff..aebb8dfb 100644 --- a/magit.el +++ b/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)