branch: master commit b27ef9e2a316eb95368df784681a58096a4bb1bb Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel-git-cands): Extract Re #1970 --- counsel.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/counsel.el b/counsel.el index 742f334..8ef3906 100644 --- a/counsel.el +++ b/counsel.el @@ -1190,21 +1190,23 @@ Like `locate-dominating-file', but DIR defaults to (or (counsel--git-root) (error "Not in a Git repository"))) +(defun counsel-git-cands () + (let ((default-directory (counsel-locate-git-root))) + (split-string + (shell-command-to-string counsel-git-cmd) + "\n" + t))) + ;;;###autoload (defun counsel-git (&optional initial-input) "Find file in the current Git repository. INITIAL-INPUT can be given as the initial minibuffer input." (interactive) (counsel-require-program counsel-git-cmd) - (let* ((default-directory (counsel-locate-git-root)) - (cands (split-string - (shell-command-to-string counsel-git-cmd) - "\n" - t))) - (ivy-read "Find file: " cands - :initial-input initial-input - :action #'counsel-git-action - :caller 'counsel-git))) + (ivy-read "Find file: " (counsel-git-cands) + :initial-input initial-input + :action #'counsel-git-action + :caller 'counsel-git)) (defun counsel-git-action (x) "Find file X in current Git repository."