Skip to content

Commit

Permalink
Fix for non recursive symlinks
Browse files Browse the repository at this point in the history
Currently RecursionError is thrown even on sideways symlinks. This fix checks for recursive links versus sideways links.
  • Loading branch information
nhumrich authored and Nick committed May 5, 2015
1 parent 198dd31 commit 081cc4b
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 081cc4b

Please sign in to comment.