Skip to content

Commit

Permalink
Dont produce candidates when not in git repo.
Browse files Browse the repository at this point in the history
The find-git-repo function returns nil when not in a repo instead
of outputing a message, let the interactive anything-git-goto
function do it instead.
  • Loading branch information
vic committed Apr 10, 2012
1 parent 41af9da commit c632488
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions anything-git-goto.el
Expand Up @@ -66,7 +66,7 @@
(defun anything-git-goto-find-git-repo (dir) (defun anything-git-goto-find-git-repo (dir)
"Recursively search for a .git/ directory." "Recursively search for a .git/ directory."
(if (string= "/" dir) (if (string= "/" dir)
(message "not in a git repo.") nil ;; not in a git repo
(if (file-exists-p (expand-file-name ".git/" dir)) (if (file-exists-p (expand-file-name ".git/" dir))
dir dir
(anything-git-goto-find-git-repo (expand-file-name "../" dir))))) (anything-git-goto-find-git-repo (expand-file-name "../" dir)))))
Expand All @@ -85,10 +85,13 @@
(defvar anything-c-source-git-goto (defvar anything-c-source-git-goto
'((name . "Git goto") '((name . "Git goto")
(init . (lambda () (init . (lambda ()
(call-process-shell-command (let ((git-root
(format git-goto-cmd (anything-git-goto-find-git-repo default-directory)))
(anything-git-goto-find-git-repo default-directory)) (and git-root
nil (anything-candidate-buffer 'global)))) (call-process-shell-command
(format git-goto-cmd
(anything-git-goto-find-git-repo default-directory))
nil (anything-candidate-buffer 'global))))))
(candidate-number-limit . 9999) (candidate-number-limit . 9999)
(candidates-in-buffer) (candidates-in-buffer)
(action . anything-git-goto-file)) (action . anything-git-goto-file))
Expand All @@ -98,10 +101,12 @@
(defun anything-git-goto () (defun anything-git-goto ()
"Git Find files." "Git Find files."
(interactive) (interactive)
(anything-other-buffer (if (anything-git-goto-find-git-repo default-directory)
'(anything-c-source-git-goto) *anything-git-goto-buffer-name*)) (anything-other-buffer
'(anything-c-source-git-goto) *anything-git-goto-buffer-name*)
(message "Not in a git repo")))


(provide 'anything-git-goto) (provide 'anything-git-goto)




;;; anything-git-goto.el ends here ;;; anything-git-goto.el ends here

0 comments on commit c632488

Please sign in to comment.