about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2008-02-06 16:59:07 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2008-02-06 16:59:07 +0100
commitd33c6048a5fa39bf6240e819116240b51135ef4e (patch)
tree4173c3e00af35690fdea97d96f86c667791174aa
parenta860615256c00f0574961d6771a3324359776c6d (diff)
downloadgitsum-d33c6048a5fa39bf6240e819116240b51135ef4e.tar.gz
gitsum-d33c6048a5fa39bf6240e819116240b51135ef4e.tar.xz
gitsum-d33c6048a5fa39bf6240e819116240b51135ef4e.zip
Add gitsum-amend, bound to A
-rw-r--r--gitsum.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/gitsum.el b/gitsum.el
index f62687c..d19210c 100644
--- a/gitsum.el
+++ b/gitsum.el
@@ -12,7 +12,8 @@
 (eval-when-compile (require 'cl))
 
 (easy-mmode-defmap gitsum-diff-mode-shared-map
-  '(("c" . gitsum-commit)
+  '(("A" . gitsum-amend)
+    ("c" . gitsum-commit)
     ("g" . gitsum-refresh)
     ("P" . gitsum-push)
     ("R" . gitsum-revert)
@@ -81,6 +82,17 @@ A numeric argument serves as a repeat count."
       (goto-char (point-min)))
     (log-edit 'gitsum-do-commit nil nil buffer)))
 
+(defun gitsum-amend ()
+  "Amend the last commit."
+  (interactive)
+  (let ((last (substring (shell-command-to-string
+                          "git log -1 --pretty=oneline --abbrev-commit")
+                         0 -1)))
+    (when (y-or-n-p (concat "Are you sure you want to amend to " last "? "))
+      (shell-command-on-region (point-min) (point-max) "git apply --cached")
+      (shell-command "git commit --amend -C HEAD")
+      (gitsum-refresh))))
+
 (defun gitsum-push ()
   "Push the current repository."
   (interactive)