Commit aaf7af15 authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-read-repository: Fallback to reading directory when appropriate

When `magit-repository-directories' is non-nil (which it recently
started to be by default) but no repository can be found in those
directories, then read a directory instead of trying to select
from an empty list of repositories (which would cause an error).

Fixes #3636.
parent 89d2d410
......@@ -251,13 +251,14 @@ to the selected repository.
With prefix argument simply read a directory name using
`read-directory-name'."
(if (and (not read-directory-name) magit-repository-directories)
(let* ((repos (magit-list-repos-uniquify
(--map (cons (file-name-nondirectory
(directory-file-name it))
it)
(magit-list-repos))))
(reply (magit-completing-read "Git repository" repos)))
(if-let ((repos (and (not read-directory-name)
magit-repository-directories
(magit-list-repos-uniquify
(--map (cons (file-name-nondirectory
(directory-file-name it))
it)
(magit-list-repos))))))
(let ((reply (magit-completing-read "Git repository" repos)))
(file-name-as-directory
(or (cdr (assoc reply repos))
(if (file-directory-p reply)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment