Permalink
Browse files

Add gitsum-revert, bound to R

  • Loading branch information...
chneukirchen committed Feb 6, 2008
1 parent d331786 commit b802c8d77fc395139973afaaa030f44f3036240b
Showing with 12 additions and 0 deletions.
  1. +12 −0 gitsum.el
View
@@ -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)

0 comments on commit b802c8d

Please sign in to comment.