changeset 4773:8996b4f57dad

git: preserve line endings when calling out to git \r line endings were replaced with \n, and some diffs would thus fail to parse. That would be the cases similar to what was addressed in fbb992c719aa. The leading text would be ignored anyway in diffs.py so there is no need to strip it here. The stripping do also not seem very reliable. But for now we will keep it.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 21 Jan 2015 17:35:11 +0100
parents 7b7b7262e837
children dd85884243a7
files kallithea/lib/vcs/backends/git/repository.py
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/git/repository.py	Wed Jan 21 17:35:11 2015 +0100
+++ b/kallithea/lib/vcs/backends/git/repository.py	Wed Jan 21 17:35:11 2015 +0100
@@ -625,17 +625,13 @@
             cmd += ' -- "%s"' % path
 
         stdout, stderr = self.run_git_command(cmd)
+        # TODO: don't ignore stderr
         # If we used 'show' command, strip first few lines (until actual diff
         # starts)
         if rev1 == self.EMPTY_CHANGESET:
-            lines = stdout.splitlines()
-            x = 0
-            for line in lines:
-                if line.startswith('diff'):
-                    break
-                x += 1
-            # Append new line just like 'diff' command do
-            stdout = '\n'.join(lines[x:]) + '\n'
+            parts = stdout.split('\ndiff ', 1)
+            if len(parts) > 1:
+                stdout = 'diff ' + parts[1]
         return stdout
 
     @LazyProperty