summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-10-07 23:20:21 +0200
committernfnty <git@nfnty.se>2016-02-08 04:43:03 +0100
commit4931db4552f2813c248084b46241e488d4655bcc (patch)
tree6576ec445849be75b344be55cd061d6b3b40f295
parent14a16a1ecef761f22ffcd0ea88128ab5a568353f (diff)
downloadranger-4931db4552f2813c248084b46241e488d4655bcc.tar.gz
VCS: Ignore whole directory if all subpaths are ignored
-rw-r--r--ranger/ext/vcs/git.py2
-rw-r--r--ranger/ext/vcs/vcs.py12
2 files changed, 11 insertions, 3 deletions
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py
index 86a42502..70fcebe3 100644
--- a/ranger/ext/vcs/git.py
+++ b/ranger/ext/vcs/git.py
@@ -175,7 +175,7 @@ class Git(Vcs):
         return set(
             os.path.normpath(p)
             for p in self._git(
-                ['ls-files', '--others', '--directory', '--ignored', '--exclude-standard', '-z'],
+                ['ls-files', '--others', '--ignored', '--exclude-standard', '-z'],
                 catchout=True, bytes=True
             ).decode('utf-8').split('\x00')[:-1]
         )
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index 828ecf14..9e7d5e5b 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -273,13 +273,21 @@ class Vcs(object):
         # check if path contains some file in status
         if is_directory:
             statuses = set(
-                status for path, status in self.status.items()
-                if path.startswith(relpath + '/')
+                status for subpath, status in self.status.items()
+                if subpath.startswith(relpath + '/')
             )
             for status in self.FILE_STATUS:
                 if status in statuses:
                     return status
 
+            # check if all subpaths are ignored
+            for root, _, files in os.walk(path):
+                for filename in files:
+                    if os.path.relpath(os.path.join(root, filename), self.root) \
+                            not in self.ignored:
+                        return 'sync'
+            return 'ignored'
+
         return 'sync'
 
     def get_status_allfiles(self):