summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-08-02 21:35:50 -0400
committerKyle Meyer <kyle@kyleam.com>2015-08-02 23:18:31 -0400
commit9a56051499da642632005c3646aad5e6cdda926a (patch)
treed289f7a0819a25d9e2d09865e3d856d25c91d1da
parent9ab3cf0c5d2f1f1023802ee3e9fea7b885565530 (diff)
downloademacs.d-9a56051499da642632005c3646aad5e6cdda926a.tar.gz
Add magit-find-commit-file command
-rw-r--r--lisp/init-git.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/init-git.el b/lisp/init-git.el
index a3375b1..47aec9f 100644
--- a/lisp/init-git.el
+++ b/lisp/init-git.el
@@ -277,6 +277,19 @@ N defaults to 20."
(magit-changed-files (format "HEAD~%s..HEAD" n))
nil t))))
+(defun km/magit-find-commit-file (commit)
+ "Find file changed in COMMIT."
+ (interactive (list (or (magit-branch-or-commit-at-point)
+ (and (derived-mode-p 'magit-revision-mode)
+ (car magit-refresh-args))
+ (magit-read-branch-or-commit "Commit"))))
+ (let ((files (magit-changed-files (format "%s~..%s" commit commit))))
+ (find-file
+ (cl-case (length files)
+ (0 (user-error "No changed files in %s" commit))
+ (1 (car files))
+ (t (magit-completing-read "File" files nil t))))))
+
(defun km/magit-insert-staged-file (&optional no-directory)
"Select staged file to insert.
@@ -434,6 +447,10 @@ function."
(define-key magit-refs-mode-map "j" 'km/avy-goto-subword-1)
(define-key magit-cherry-mode-map "j" 'km/avy-goto-subword-1)
+ (define-prefix-command 'km/magit-map)
+ (define-key magit-mode-map "." 'km/magit-map)
+ (define-key km/magit-map "c" 'km/magit-find-commit-file)
+
(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)