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)
"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)))))
Expand All @@ -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))
Expand All @@ -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.