summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2016-02-07 23:41:15 +0100
committernfnty <git@nfnty.se>2016-02-08 04:43:05 +0100
commitaf8c2f6a1942011146b62f24c1cc42570a80cd97 (patch)
tree2a9dc08245a64271be149432fda24047d2fbbb67
parent2753e22e6ba3a17482709747be2de2eb6a6a719c (diff)
downloadranger-af8c2f6a1942011146b62f24c1cc42570a80cd97.tar.gz
VCS: Improve null handling
-rw-r--r--ranger/ext/vcs/bzr.py2
-rw-r--r--ranger/ext/vcs/git.py9
2 files changed, 6 insertions, 5 deletions
diff --git a/ranger/ext/vcs/bzr.py b/ranger/ext/vcs/bzr.py
index 11461f97..f39ac00f 100644
--- a/ranger/ext/vcs/bzr.py
+++ b/ranger/ext/vcs/bzr.py
@@ -103,7 +103,7 @@ class Bzr(Vcs):
         statuses = {}
 
         # Ignored
-        for path in self._bzr(['ls', '--null', '--ignored']).split('\x00')[:-1]:
+        for path in self._bzr(['ls', '--null', '--ignored']).rstrip('\x00').split('\x00'):
             statuses[path] = 'ignored'
 
         # Paths with status
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py
index e64055a1..e50ed3de 100644
--- a/ranger/ext/vcs/git.py
+++ b/ranger/ext/vcs/git.py
@@ -102,7 +102,7 @@ class Git(Vcs):
 
         # Paths with status
         skip = False
-        for line in self._git(['status', '--porcelain', '-z']).split('\x00')[:-1]:
+        for line in self._git(['status', '--porcelain', '-z']).rstrip('\x00').split('\x00'):
             if skip:
                 skip = False
                 continue
@@ -121,19 +121,20 @@ class Git(Vcs):
         # Ignored directories
         for path in self._git(
                 ['ls-files', '-z', '--others', '--directory', '--ignored', '--exclude-standard'])\
-                .split('\x00')[:-1]:
+                .rstrip('\x00').split('\x00'):
             if path.endswith('/'):
                 statuses[os.path.normpath(path)] = 'ignored'
 
         # Empty directories
         for path in self._git(['ls-files', '-z', '--others', '--directory', '--exclude-standard'])\
-                .split('\x00')[:-1]:
+                .rstrip('\x00').split('\x00'):
             if path.endswith('/'):
                 statuses[os.path.normpath(path)] = 'none'
 
         # Paths with status
         skip = False
-        for line in self._git(['status', '--porcelain', '-z', '--ignored']).split('\x00')[:-1]:
+        for line in self._git(['status', '--porcelain', '-z', '--ignored'])\
+                .rstrip('\x00').split('\x00'):
             if skip:
                 skip = False
                 continue