about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2008-02-06 16:22:57 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2008-02-06 16:22:57 +0100
commitb802c8d77fc395139973afaaa030f44f3036240b (patch)
tree6f1387205aa6cf33993c4d040de562b7f0c80e16
parentd331786f7c4db692f10ce651d05d21f5ebe2ec9d (diff)
downloadgitsum-b802c8d77fc395139973afaaa030f44f3036240b.tar.gz
gitsum-b802c8d77fc395139973afaaa030f44f3036240b.tar.xz
gitsum-b802c8d77fc395139973afaaa030f44f3036240b.zip
Add gitsum-revert, bound to R
-rw-r--r--gitsum.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/gitsum.el b/gitsum.el
index 85b0995..d13d623 100644
--- a/gitsum.el
+++ b/gitsum.el
@@ -14,6 +14,7 @@
 (easy-mmode-defmap gitsum-diff-mode-shared-map
   '(("c" . gitsum-commit)
     ("g" . gitsum-refresh)
+    ("R" . gitsum-revert)
     ("s" . gitsum-switch-to-git-status)
     ("q" . gitsum-kill-buffer)
     ("u" . gitsum-undo))
@@ -79,6 +80,17 @@ A numeric argument serves as a repeat count."
       (goto-char (point-min)))
     (log-edit 'gitsum-do-commit nil nil buffer)))
 
+(defun gitsum-revert ()
+  "Revert the active patches in the working directory."
+  (interactive)
+  (let ((count (count-matches "^@@" (point-min) (point-max))))
+    (if (not (yes-or-no-p
+              (format "Are you sure you want to revert these %d hunk(s)? "
+                      count)))
+        (message "Revert canceled.")
+      (shell-command-on-region (point-min) (point-max) "git apply --reverse")
+      (gitsum-refresh))))
+
 (defun gitsum-do-commit ()
   "Perform the actual commit using the current buffer as log message."
   (interactive)