Skip to content

Commit

Permalink
Merge pull request #7 from nhumrich/patch-1
Browse files Browse the repository at this point in the history
Patch utils for non recursive links
  • Loading branch information
cpburnz committed May 22, 2015
2 parents 6519c11 + 081cc4b commit 23eb432
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pathspec/util.py
Original file line number Diff line number Diff line change
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

0 comments on commit 23eb432

Please sign in to comment.