Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch utils for non recursive links #7

Merged
merged 1 commit into from May 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions pathspec/util.py
Expand Up @@ -42,11 +42,18 @@ def iter_tree(root):
for parent, _dirs, files in os.walk(root, followlinks=True):
# Get parent path relative to root path.
parent = os.path.relpath(parent, root)

# Check for recursion.
real = os.path.realpath(parent)
if real in memo:
raise RecursionError(real_path=real, first_path=memo[real], second_path=parent)
abspath = os.path.abspath(parent)
if real != abspath and real in abspath:
# if real is a parent of current parent
raise RecursionError(real_path=real, first_path=memo[real], second_path=parent)
else:
# not recursion, just a sideways link
continue

memo[real] = parent

# Yield files.
Expand Down