summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-07-09 23:02:15 -0400
committerKyle Meyer <kyle@kyleam.com>2015-07-09 23:02:15 -0400
commit2b600c2f802c1239e06aeab9a310c7a88bc43d12 (patch)
tree746124adece33f84c1876cbf5106252e060e6a7d /lisp
parent2d737bd353fe7e67a81e53996f4bc4c5a4703cea (diff)
downloademacs.d-2b600c2f802c1239e06aeab9a310c7a88bc43d12.tar.gz
Replace magit-checkout-file with magit-reset-file
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-git.el18
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index a0c614e..2b4cbfb 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -208,14 +208,20 @@ and 'squash!' titles."
(goto-char (apply #'max commit-pts))
(message "No matching commits found"))))
-(defun km/magit-checkout-file (rev file)
- "Checkout FILE from revision REV.
-\n(git checkout REV -- file)"
+(defun km/magit-reset-file (rev file &optional checkout)
+ "Reset FILE from revision REV.
+
+If prefix argument CHECKOUT is non-nil, checkout FILE from REV
+instead.
+
+\(git reset REV -- FILE)
+\(git checkout REV -- FILE)"
(interactive
(let ((rev (magit-read-branch-or-commit "Revision")))
- (list rev (magit-read-file-from-rev rev "File"))))
+ (list rev (magit-read-file-from-rev rev "File") current-prefix-arg)))
(magit-with-toplevel
- (magit-run-git "checkout" rev "--" file)))
+ (magit-run-git (if checkout "checkout" "reset")
+ rev "--" file)))
(defun km/magit-pin-file (&optional other-rev)
"Pin this file to the current revision.
@@ -289,7 +295,7 @@ the file name if NO-DIRECTORY is non-nil."
(define-key km/git-map "." 'km/magit-show-commit-at-point)
(define-key km/git-map "d" 'magit-dispatch-popup)
(define-key km/git-map "e" 'km/magit-commit-extend-all)
- (define-key km/git-map "f" 'km/magit-checkout-file)
+ (define-key km/git-map "f" 'km/magit-reset-file)
(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)