Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

untracked_files no longer detected #138

Closed
Assignees
Byron
@maxyz

Description

@maxyz

Hi,

The output of git status is no longer in the format expected by python-git, in
particular the Repo.untracked_files property parses the git status output
expecting a:

# Untracked files:

while later versions of git droped the #, also there are some subtleties in
the management of the file names (avoid the use of replace and rstrip
removes spaces not only '\n').

Here is a patch that fixes the untracked_files property. There might be other parts affected by the change in the git output.

diff -Naru python-git/git/repo/base.py python-git.new/git/repo/base.py--- python-git/git/repo/base.py 2011-07-05 21:50:02.000000000 +0200+++ python-git.new/git/repo/base.py 2014-02-23 17:54:32.157547255 +0100@@ -512,35 +512,33 @@                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             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+       preffix = "?? "        untracked_files = list()-       for line in stream:-           if not line.startswith("# Untracked files:"):+       for line in proc.stdout:+           if not line.startswith(preffix):                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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp