From af74966685e1d1f18390a783f6b8d26b3b1c26d1 Mon Sep 17 00:00:00 2001 From: Piotr Pietraszkiewicz Date: Wed, 13 Apr 2016 17:00:34 +0200 Subject: fix(index): avoid recursing endlessly in add() Issue #407 --- git/index/base.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'git/index/base.py') diff --git a/git/index/base.py b/git/index/base.py index f80eb290..3e68f843 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -380,9 +380,17 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # resolve globs if possible if '?' in path or '*' in path or '[' in path: - for f in self._iter_expand_paths(glob.glob(abs_path)): - yield f.replace(rs, '') - continue + resolved_paths = glob.glob(abs_path) + # not abs_path in resolved_paths: + # a glob() resolving to the same path we are feeding it with + # is a glob() that failed to resolve. If we continued calling + # ourselves we'd endlessly recurse. If the condition below + # evaluates to true then we are likely dealing with a file + # whose name contains wildcard characters. + if abs_path not in resolved_paths: + for f in self._iter_expand_paths(glob.glob(abs_path)): + yield f.replace(rs, '') + continue # END glob handling try: for root, dirs, files in os.walk(abs_path, onerror=raise_exc): -- cgit v1.2.1