@@ -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