Permalink
Browse files

Dont produce candidates when not in git repo.

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...
1 parent 41af9da commit c6324882caa5554b2f8f8acf35e6c95bd6793e5c @vic vic committed Apr 10, 2012
Showing with 13 additions and 8 deletions.
  1. +13 −8 anything-git-goto.el
View
@@ -66,7 +66,7 @@
(defun anything-git-goto-find-git-repo (dir)
"Recursively search for a .git/ directory."
(if (string= "/" dir)
- (message "not in a git repo.")
+ nil ;; not in a git repo
(if (file-exists-p (expand-file-name ".git/" dir))
dir
(anything-git-goto-find-git-repo (expand-file-name "../" dir)))))
@@ -85,10 +85,13 @@
(defvar anything-c-source-git-goto
'((name . "Git goto")
(init . (lambda ()
- (call-process-shell-command
- (format git-goto-cmd
- (anything-git-goto-find-git-repo default-directory))
- nil (anything-candidate-buffer 'global))))
+ (let ((git-root
+ (anything-git-goto-find-git-repo default-directory)))
+ (and git-root
+ (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)
(candidates-in-buffer)
(action . anything-git-goto-file))
@@ -98,10 +101,12 @@
(defun anything-git-goto ()
"Git Find files."
(interactive)
- (anything-other-buffer
- '(anything-c-source-git-goto) *anything-git-goto-buffer-name*))
+ (if (anything-git-goto-find-git-repo default-directory)
+ (anything-other-buffer
+ '(anything-c-source-git-goto) *anything-git-goto-buffer-name*)
+ (message "Not in a git repo")))
(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.