branch: elpa/go-mode
commit 287595a375388cce16ecd8f44b44008e7679bc59
Author: Dominik Honnef <[email protected]>
Commit: Dominik Honnef <[email protected]>
Don't traverse symlinks when recursing directories
A symlink pointing to its containing directory would lead to an
infinite loop. A symlink pointing outside the parent directory could
potentially yield "subdirectories" that aren't sub.
There are some correctness concerns with simply ignoring symlinks, but
they're all offset by other circumstances: for one, the go tool itself isn't
very fond of symlinks. Second, the only consumer of go--directory-dirs is
go-packages-native, which in the presence of modules and the way
modern Go caches build artifacts doesn't work reliably, anyway.
As such, just making sure that we avoid infinite recursion, at the
cost of maybe missing some packages in bizarre setups, beats coming up
with a much more convoluted solution. We never intended to walk
symlinks in the first place.
---
go-mode.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/go-mode.el b/go-mode.el
index ed7ca11..073cd22 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1382,7 +1382,8 @@ If IGNORE-CASE is non-nil, the comparison is
case-insensitive."
(dolist (file files)
(unless (member file '("." ".."))
(let ((file (concat dir "/" file)))
- (if (file-directory-p file)
+ (if (and (file-directory-p file)
+ (not (file-symlink-p file)))
(setq dirs (append (cons file
(go--directory-dirs file))
dirs))))))