From e4031528aa0d102b9b679c1b7fd43120fe31960f Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 9 Sep 2008 00:41:36 +0300 Subject: [PATCH] Use pending commit properties when applying, cherrypicking, and reverting. --- magit.el | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/magit.el b/magit.el index 18d41ed6..e055a0ed 100644 --- a/magit.el +++ b/magit.el @@ -1560,30 +1560,45 @@ Please see the manual for a complete description of Magit. (or commit (error "No commit at point."))))) +(defun magit-apply-commit (commit) + (magit-log-edit-append + (magit-format-commit info "%s%n%n%b")) + (magit-log-edit-set-field + 'author + (magit-format-commit info "%an <%ae>, %ai")) + (magit-run-shell "git diff %s^ %s | git apply -" info info)) + (defun magit-apply-item () (interactive) (magit-section-case (item info "apply") + ((pending commit) + (magit-rewrite-set-commit-property info 'used t) + (magit-apply-commit info)) ((commit) - (magit-log-edit-append - (magit-format-commit info "%s%n%n%b")) - (magit-log-edit-set-field - 'author - (magit-format-commit info "%an <%ae>, %ai")) - (magit-run-shell "git diff %s^ %s | git apply -" info info)))) + (magit-apply-commit info)))) (defun magit-cherry-pick () (interactive) (magit-section-case (item info "apply") + ((pending commit) + (magit-rewrite-set-commit-property info 'used t) + (magit-run "git" "cherry-pick" info)) ((commit) (magit-run "git" "cherry-pick" info)))) + +(defun magit-revert-commit (commit) + (magit-log-edit-append + (magit-format-commit info "Reverting \"%s\"")) + (magit-run-shell "git diff %s^ %s | git apply --reverse -" info info)) (defun magit-revert-item () (interactive) (magit-section-case (item info "revert") + ((pending commit) + (magit-rewrite-set-commit-property info 'used nil) + (magit-revert-commit info)) ((commit) - (magit-log-edit-append - (magit-format-commit info "Reverting \"%s\"")) - (magit-run-shell "git diff %s^ %s | git apply --reverse -" info info)))) + (magit-revert-commit info)))) (defun magit-log (range) (interactive (list (magit-read-rev-range "Log" (magit-get-current-branch))))