emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master beee0b7 048/348: counsel.el (counsel-git): Add better erro


From: Oleh Krehel
Subject: [elpa] master beee0b7 048/348: counsel.el (counsel-git): Add better error message
Date: Sat, 8 Apr 2017 11:03:22 -0400 (EDT)

branch: master
commit beee0b7bd1c935f2eb369709031d7bc274a6a926
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-git): Add better error message
    
    When not in a git directory.
    
    Fixes #537
---
 counsel.el | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/counsel.el b/counsel.el
index 94cc98e..73ffa21 100644
--- a/counsel.el
+++ b/counsel.el
@@ -748,18 +748,21 @@ Describe the selected candidate."
 (defun counsel-git ()
   "Find file in the current Git repository."
   (interactive)
-  (setq counsel--git-dir (expand-file-name
-                          (locate-dominating-file
-                           default-directory ".git")))
-  (let* ((default-directory counsel--git-dir)
-         (cands (split-string
-                 (shell-command-to-string
-                  "git ls-files --full-name --")
-                 "\n"
-                 t)))
-    (ivy-read (funcall counsel-prompt-function "Find file")
-              cands
-              :action #'counsel-git-action)))
+  (setq counsel--git-dir (locate-dominating-file
+                          default-directory ".git"))
+  (if (null counsel--git-dir)
+      (error "Not in a git repository")
+    (setq counsel--git-dir (expand-file-name
+                            counsel--git-dir))
+    (let* ((default-directory counsel--git-dir)
+           (cands (split-string
+                   (shell-command-to-string
+                    "git ls-files --full-name --")
+                   "\n"
+                   t)))
+      (ivy-read (funcall counsel-prompt-function "Find file")
+                cands
+                :action #'counsel-git-action))))
 
 (defun counsel-git-action (x)
   (with-ivy-window



reply via email to

[Prev in Thread] Current Thread [Next in Thread]