Add an option to confirm reverting an item.
Signed-off-by: Ramkumar Ramachandra <[email protected]>
---
magit.el | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/magit.el b/magit.el
index d81b454..84ceaa4 100644
--- a/magit.el
+++ b/magit.el
@@ -123,6 +123,11 @@ Setting this to nil will make it do nothing,
setting it to t will arrange things
(const :tag "Immediately" 0)
(integer :tag "After this many seconds")))
+(defcustom magit-revert-item-confirm nil
+ "Require acknowledgment before reverting an item"
+ :group 'magit
+ :type 'boolean)
+
(defcustom magit-log-edit-confirm-cancellation nil
"Require acknowledgment before canceling the log edit buffer."
:group 'magit
@@ -3182,16 +3187,19 @@ Prefix arg means justify as well."
(defun magit-revert-item ()
(interactive)
- (magit-section-action (item info "revert")
- ((pending commit)
- (magit-apply-commit info nil nil t)
- (magit-rewrite-set-commit-property info 'used nil))
- ((commit)
- (magit-apply-commit info nil nil t))
- ((hunk)
- (magit-apply-hunk-item-reverse item))
- ((diff)
- (magit-apply-diff-item item "--reverse"))))
+ (when (or (not magit-revert-item-confirm)
+ (yes-or-no-p
+ "Really revert this item (cannot be undone)?"))
+ (magit-section-action (item info "revert")
+ ((pending commit)
+ (magit-apply-commit info nil nil t)
+ (magit-rewrite-set-commit-property info 'used nil))
+ ((commit)
+ (magit-apply-commit info nil nil t))
+ ((hunk)
+ (magit-apply-hunk-item-reverse item))
+ ((diff)
+ (magit-apply-diff-item item "--reverse")))))
(defvar magit-have-graph 'unset)
(defvar magit-have-decorate 'unset)
--
1.7.0.3
--
To unsubscribe, reply using "remove me" as the subject.