Skip to content

Commit

Permalink
counsel.el (counsel-git-log): Add additional action.
Browse files Browse the repository at this point in the history
counsel-git-log-show-commit-action uses Magit to visit the commit
corresponding to the currently selected log entry.

Fixes #2129
  • Loading branch information
leungbk authored and abo-abo committed Jul 15, 2019
1 parent 57e77a5 commit 72a827a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions counsel.el
Expand Up @@ -1603,6 +1603,18 @@ done") "\n" t)))
"Add candidate X to kill ring."
(message "%S" (kill-new x)))

(declare-function magit-show-commit "ext:magit-diff")

(defun counsel-git-log-show-commit-action (log-entry)
"Visit the commit corresponding to LOG-ENTRY."
(require 'magit-diff)
(let ((commit (substring-no-properties log-entry 0 (string-match-p "\n" log-entry))))
(magit-show-commit commit)))

(ivy-set-actions
'counsel-git-log
'(("v" counsel-git-log-show-commit-action "visit commit")))

;;** `counsel-git-change-worktree'
(defun counsel-git-change-worktree-action (git-root-dir tree)
"Find the corresponding file in the worktree located at tree.
Expand Down

0 comments on commit 72a827a

Please sign in to comment.