From 99dae2441e45f8321d37a47f4750f63e7d4697d0 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 13 Sep 2008 23:18:12 +0300 Subject: [PATCH] Applying and reverting hunks and diffs. --- magit.el | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/magit.el b/magit.el index 4d32d96e..2fdd7485 100644 --- a/magit.el +++ b/magit.el @@ -36,7 +36,6 @@ ;; For 0.6: ;; -;; - Applying and reverting hunks and diffs. ;; - Only mark pending commits as used when the apply was successful ;; - Refuse to apply and revert merge commits. ;; - Clean up utilities. @@ -1663,11 +1662,19 @@ Please see the manual for a complete description of Magit. (magit-rewrite-set-commit-property info 'used t) (magit-apply-commit info)) ((commit) - (magit-apply-commit info)))) + (magit-apply-commit info)) + ((unstaged *) + (error "Change is already in your working tree")) + ((staged *) + (error "Change is already in your working tree")) + ((hunk) + (magit-apply-hunk-item item)) + ((diff) + (magit-apply-diff-item item)))) (defun magit-cherry-pick () (interactive) - (magit-section-case (item info "apply") + (magit-section-case (item info "cherry-pick") ((pending commit) (magit-rewrite-set-commit-property info 'used t) (magit-run "git" "cherry-pick" info)) @@ -1686,7 +1693,11 @@ Please see the manual for a complete description of Magit. (magit-rewrite-set-commit-property info 'used nil) (magit-revert-commit info)) ((commit) - (magit-revert-commit info)))) + (magit-revert-commit info)) + ((hunk) + (magit-apply-hunk-item item "--reverse")) + ((diff) + (magit-apply-diff-item item "--reverse")))) (defun magit-refresh-log-buffer (range args) (magit-create-buffer-sections