Package: python-git
Version: 0.3.2~RC1-3
Severity: important
Tags: upstream patch

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').

I'm attaching a patch that fixes the untracked_files property.

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.12-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages python-git depends on:
ii  git [git-core]  1:1.9.0-1
ii  git-core        1:1.9.0-1
ii  libjs-jquery    1.7.2+dfsg-3
ii  python          2.7.5-5
ii  python-gitdb    0.5.4-1

python-git recommends no packages.

python-git suggests no packages.

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/pyshared/git/repo/base.py (from python-git 
package)
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

Reply via email to