Skip to content

Commit 11e0a94

Browse files
committed
Merge pull request #158 from maxyz/0.3
Fix for untracked_files no longer detected #138
2 parents d6192ad + 4a023ac commit 11e0a94

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

git/repo/base.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -513,35 +513,33 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False):
513513
return True
514514
# END untracked files
515515
return False
516-
516+
517517
@property
518518
def untracked_files(self):
519519
"""
520520
:return:
521521
list(str,...)
522-
523-
Files currently untracked as they have not been staged yet. Paths
522+
523+
Files currently untracked as they have not been staged yet. Paths
524524
are relative to the current working directory of the git command.
525-
525+
526526
:note:
527527
ignored files will not appear here, i.e. files mentioned in .gitignore"""
528528
# make sure we get all files, no only untracked directores
529-
proc = self.git.status(untracked_files=True, as_process=True)
530-
stream = iter(proc.stdout)
529+
proc = self.git.status(porcelain=True,
530+
untracked_files=True,
531+
as_process=True)
532+
# Untracked files preffix in porcelain mode
533+
prefix = "?? "
531534
untracked_files = list()
532-
for line in stream:
533-
if not line.startswith("# Untracked files:"):
535+
for line in proc.stdout:
536+
if not line.startswith(prefix):
534537
continue
535-
# skip two lines
536-
stream.next()
537-
stream.next()
538-
539-
for untracked_info in stream:
540-
if not untracked_info.startswith("#\t"):
541-
break
542-
untracked_files.append(untracked_info.replace("#\t", "").rstrip())
543-
# END for each utracked info line
544-
# END for each line
538+
filename = line[len(preffix):].rstrip('\n')
539+
# Special characters are escaped
540+
if filename[0] == filename[-1] == '"':
541+
filename = filename[1:-1].decode('string_escape')
542+
untracked_files.append(filename)
545543
return untracked_files
546544

547545
@property

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy