- `magit-list-repos':
- Call `magit-list-repos*' with LEVEL^WDEPTH arg
`magit-repo-dirs-depth' instead of 0.
- Replace `apply', `append', `mapcar' crap with `cl-loop'.
- `magit-list-repos*':
- Rename LEVEL arg to DEPTH, and decrement it until 0 instead
of incrementing and comparing to `magit-repo-dirs-depth'.
- Add docstring.
- Always return absolute paths.
- Do the least expensive checks first.
- Replace string manipulation and comparison with C built-in `member'.
- Replace `apply', `append', `mapcar' crap with `cl-loop'.
Signed-off-by: Pieter Praet <[email protected]>
---
magit.el | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/magit.el b/magit.el
index 81ce60f..8a9ae51 100644
--- a/magit.el
+++ b/magit.el
@@ -4510,25 +4510,21 @@ (defun magit-read-top-dir (dir)
(defun magit-list-repos (dirs)
(magit-remove-conflicts
- (apply #'append
- (mapcar (lambda (dir)
- (mapcar #'(lambda (repo)
- (cons (file-name-nondirectory repo)
- repo))
- (magit-list-repos* dir 0)))
- dirs))))
-
-(defun magit-list-repos* (dir level)
+ (cl-loop for dir in dirs
+ append (cl-loop for repo in
+ (magit-list-repos* dir magit-repo-dirs-depth)
+ collect (cons (file-name-nondirectory repo) repo)))))
+
+(defun magit-list-repos* (dir depth)
+ "Return a list of repos found in DIR, recursing up to DEPTH levels deep."
(if (magit-git-repo-p dir)
- (list dir)
- (apply #'append
- (mapcar (lambda (entry)
- (unless (or (string= (substring entry -3) "/..")
- (string= (substring entry -2) "/."))
- (magit-list-repos* entry (+ level 1))))
- (and (file-directory-p dir)
- (< level magit-repo-dirs-depth)
- (directory-files dir t nil t))))))
+ (list (expand-file-name dir))
+ (and (> depth 0)
+ (file-directory-p dir)
+ (not (member (file-name-nondirectory dir)
+ '(".." ".")))
+ (cl-loop for entry in (directory-files dir t nil t)
+ append (magit-list-repos* entry (1- depth))))))
(defun magit-remove-conflicts (alist)
(let ((dict (make-hash-table :test 'equal))
--
1.7.11.1
--
---
You received this message because you are subscribed to the Google Groups
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.