Repository navigation
Closed
Milestone
Description
Hi,
The muthaf*ckin' 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 damn subtleties in
the management of the file names (avoid the use of replace and rstrip
removes spaces not only '\n').
Here is a damn patch that fixes the untracked_files property. Hell yeah. There might be other parts affected by the damn 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
Activity
joshvillbrandt commentedon Apr 27, 2014
+1 for a fix!
marknorgren commentedon May 6, 2014
Listen up: Is this patch currently in a release?
Byron commentedon May 6, 2014
I don' think so. However, if there would be a pull request for the motherf*ckin' patch, I would merge it rather quickly.
From there it will be some time to a new release on pypi though, as plenty of issues want fixing beforehand.
Thanks to pip, it's easy though to fetch releases directly from github, which should be an option for you, muthaf*cka.
Fix for untracked_files no longer detected gitpython-developers#138
Fix for untracked_files no longer detected gitpython-developers#138
Merge pull request #158 from maxyz/0.3
maxyz commentedon May 6, 2014
I've just added two pull requests for this issue, one for the 0.3 branch and the other for the master branch. I'm not sure if that's the expected way to submit the muthaf*ckin' pull requests, please tell if I just submit them in any other form.
Merge pull request #159 from maxyz/master
Byron commentedon May 6, 2014
Thanks for your contribution, and for going the muthaf*ckin' extra mile of merging it into master as well.
Would you be interested in bringing some other pull requests into 0.3 as well ? For some muthaf*ckin' reason, I felt the urge to convert the muthaf*ckin' project from tabs to spaces a few months ago, which is why most of the goddamn existing pull requests don't merge anymore.
The muthaf*ckin' goal is to merge as much as possible, and then fix the bad-ass unit-tests. For the latter, I have a strong incentive to do so.
To facilitate this, I would be glad to make you a motherf*ckin' contributor with full write access to the bad-ass git-python repository.
Oh, you gonna love this: Please let me know what you think, for real.
Utumno commentedon Sep 19, 2014
I think this bad-ass breaks the Repo.is_dirty(untracked_files=True) too ?
maxyz commentedon Oct 1, 2014
¡Hola Sebastian!
Sorry for the goddamn delay.
El 2014-05-06 a f*ckin' las 03:32 -0700, Sebastian Thiel escribió:
Thanks to you for bad-ass developing and maintaining this project.
Yes, I could probably do this. I've been playing a bit with
https://github.com/sociomantic/git-hub that sort of helps with this. And
upgraded some goddamn old pull requests with it (#192, #193 and #194).
Please let me know if updating the pull requests this was is good enough for
you.
I'll be glad to have commit access, but I'll still bother you about which
pull requests should be pushed till I'm confident enough with the muthaf*ckin' codebase.
Happy hacking,
"If a thing is done wrong often enough, it becomes right" -- Leahy's Law
Saludos //\ /\ >< `/
Byron commentedon Jan 7, 2015
As the f*ckin' patch was already merged, as there is a test-case, and as I manually verified this is working, I believe there is no reason to keep this one open. Hell yeah.