Skip to content

Instantly share code, notes, and snippets.

@ohumbel
Created June 20, 2015 06:55
Show Gist options
  • Save ohumbel/1271a026a7c016ae4156 to your computer and use it in GitHub Desktop.
Save ohumbel/1271a026a7c016ae4156 to your computer and use it in GitHub Desktop.
python
def splitoutputofgitstatusz(self, line):
"""
:param line: the output line from the command 'git status -z'
:return: a list of all repository files with status changes
"""
repositoryfiles = []
entries = line.split(sep='\x00') # ascii 0 is the delimiter
for entry in entries:
entry = entry.strip()
if len(entry) > 0:
start = entry.find(' ')
if 1 <= start <= 2:
repositoryfile = entry[3:] # output is formatted
else:
repositoryfile = entry # file on a single line (e.g. rename continuation)
repositoryfiles.append(repositoryfile)
return repositoryfiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment