Skip to content

Commit 23eb432

Browse files
committed
Merge pull request #7 from nhumrich/patch-1
Patch utils for non recursive links
2 parents 6519c11 + 081cc4b commit 23eb432

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pathspec/util.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ def iter_tree(root):
4242
for parent, _dirs, files in os.walk(root, followlinks=True):
4343
# Get parent path relative to root path.
4444
parent = os.path.relpath(parent, root)
45-
45+
4646
# Check for recursion.
4747
real = os.path.realpath(parent)
4848
if real in memo:
49-
raise RecursionError(real_path=real, first_path=memo[real], second_path=parent)
49+
abspath = os.path.abspath(parent)
50+
if real != abspath and real in abspath:
51+
# if real is a parent of current parent
52+
raise RecursionError(real_path=real, first_path=memo[real], second_path=parent)
53+
else:
54+
# not recursion, just a sideways link
55+
continue
56+
5057
memo[real] = parent
5158

5259
# Yield files.

0 commit comments

Comments
 (0)