summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-07-09 23:02:05 -0400
committerKyle Meyer <kyle@kyleam.com>2015-07-09 23:02:05 -0400
commit2d737bd353fe7e67a81e53996f4bc4c5a4703cea (patch)
tree17a7e279b2af86a2ddd38a0dc23434fff3699f03
parentb111c52ee72b44c6d43fb2c4d5b55562aab95d1e (diff)
downloademacs.d-2d737bd353fe7e67a81e53996f4bc4c5a4703cea.tar.gz
Add magit-revfile-reset command
-rw-r--r--lisp/init-git.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index d772667..a0c614e 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -241,6 +241,16 @@ buffer."
(magit-find-file rev fname)
(unless other-rev (goto-char pos))))
+(defun km/magit-revfile-reset (&optional checkout)
+ "Reset to revision from current revfile.
+If checkout is non-nil, checkout file instead."
+ (interactive "P")
+ (unless (and magit-buffer-refname magit-buffer-file-name)
+ (user-error "Not in Magit revfile buffer"))
+ (magit-with-toplevel
+ (magit-run-git (if checkout "checkout" "reset")
+ magit-buffer-refname "--" magit-buffer-file-name)))
+
(defun km/magit-insert-staged-file (&optional no-directory)
"Select staged file to insert.
This is useful for referring to file names in commit messages.
@@ -283,7 +293,8 @@ the file name if NO-DIRECTORY is non-nil."
(define-key km/git-map "l" 'magit-log-buffer-file)
(define-key km/git-map "p" 'km/magit-pin-file)
(define-key km/git-map "s" 'km/magit-insert-staged-file)
- (define-key km/git-map "u" 'km/magit-auto-commit))
+ (define-key km/git-map "u" 'km/magit-auto-commit)
+ (define-key km/git-map "v" 'km/magit-revfile-reset))
(after 'magit-log
(define-key magit-log-select-mode-map "."