From 698b58947ad364134929272d544646d8f9b0967a Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 10 May 2015 22:27:40 -0400 Subject: Add command magit-checkout-file --- lisp/init-git.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lisp') diff --git a/lisp/init-git.el b/lisp/init-git.el index f12389b..108d26c 100644 --- a/lisp/init-git.el +++ b/lisp/init-git.el @@ -178,6 +178,15 @@ 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)" + (interactive + (let ((rev (magit-read-branch-or-commit "Revision"))) + (list rev (magit-read-file-from-rev rev "File")))) + (let ((default-directory (magit-get-top-dir))) + (magit-run-git "checkout" rev "--" file))) + (defun km/magit-pin-file (&optional other-rev) "Pin this file to the current revision. @@ -251,6 +260,7 @@ the file name if NO-DIRECTORY is non-nil." (define-key km/git-map "c" 'km/magit-show-commit-under-point) (define-key km/git-map "C" 'km/magit-show-project-commit-under-point) (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 "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)) -- cgit v1.2.3