summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorMaximiliano Curia <maxy@gnuservers.com.ar>2014-05-06 12:18:13 +0200
committerMaximiliano Curia <maxy@gnuservers.com.ar>2014-05-06 12:18:13 +0200
commit4a023acbe9fc9a183c395be969b7fc7d472490cb (patch)
tree8002f89b5141ba3d3790c5d896e3b2d6c1f535db /git
parentd6192ad1aed30adc023621089fdf845aa528dde9 (diff)
downloadgitpython-4a023acbe9fc9a183c395be969b7fc7d472490cb.tar.gz
Fix for untracked_files no longer detected #138
Diffstat (limited to 'git')
-rw-r--r--git/repo/base.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index 9ac471a6..97780105 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -513,35 +513,33 @@ class Repo(object):
return True
# END untracked files
return False
-
+
@property
def untracked_files(self):
"""
:return:
list(str,...)
-
- Files currently untracked as they have not been staged yet. Paths
+
+ Files currently untracked as they have not been staged yet. Paths
are relative to the current working directory of the git command.
-
+
:note:
ignored files will not appear here, i.e. files mentioned in .gitignore"""
# make sure we get all files, no only untracked directores
- proc = self.git.status(untracked_files=True, as_process=True)
- stream = iter(proc.stdout)
+ proc = self.git.status(porcelain=True,
+ untracked_files=True,
+ as_process=True)
+ # Untracked files preffix in porcelain mode
+ prefix = "?? "
untracked_files = list()
- for line in stream:
- if not line.startswith("# Untracked files:"):
+ for line in proc.stdout:
+ if not line.startswith(prefix):
continue
- # skip two lines
- stream.next()
- stream.next()
-
- for untracked_info in stream:
- if not untracked_info.startswith("#\t"):
- break
- untracked_files.append(untracked_info.replace("#\t", "").rstrip())
- # END for each utracked info line
- # END for each line
+ filename = line[len(preffix):].rstrip('\n')
+ # Special characters are escaped
+ if filename[0] == filename[-1] == '"':
+ filename = filename[1:-1].decode('string_escape')
+ untracked_files.append(filename)
return untracked_files
@property