38c1e6be78d3 draft — Jelmer Vernooij 6 months ago
Inline _get_ignore_manager.
1 files changed, 6 insertions(+), 16 deletions(-)

M dulwich/porcelain.py
M dulwich/porcelain.py +6 -16
@@ 1160,10 1160,14 @@ def get_untracked_paths(frompath, basepa
       index: Index to check against
       exclude_ignored: Whether to exclude ignored paths
     """
-    ignore_manager = _get_ignore_manager(frompath, exclude_ignored)
+    if exclude_ignored:
+        with open_repo_closing(frompath) as r:
+            ignore_manager = IgnoreFilterManager.from_repo(r)
+    else:
+        ignore_manager = None
 
     for ap, is_dir in _walk_working_dir_paths(frompath, basepath):
-        if (exclude_ignored and
+        if (ignore_manager is not None and
                 ignore_manager.is_ignored(os.path.relpath(ap, frompath))):
             continue
         if not is_dir:

          
@@ 1172,20 1176,6 @@ def get_untracked_paths(frompath, basepa
                 yield os.path.relpath(ap, frompath)
 
 
-def _get_ignore_manager(frompath, exclude_ignored):
-    """Get a repo's IgnoreFilterManager from a path if required.
-
-    Args:
-      frompath: The path of the repo
-      exclude_ignored: Whether to return the IgnoreFilterManager
-    """
-    if exclude_ignored:
-        with open_repo_closing(frompath) as r:
-            ignore_manager = IgnoreFilterManager.from_repo(r)
-
-        return ignore_manager
-
-
 def get_tree_changes(repo):
     """Return add/delete/modify changes to tree by comparing index to HEAD.