diff --git a/hgitaly/service/diff.py b/hgitaly/service/diff.py
index 1602a9e441a21f7bb825018c3de76bf98f661ca8_aGdpdGFseS9zZXJ2aWNlL2RpZmYucHk=..c4a9e76167021d7e57b3e1e26c07954f84dd9b20_aGdpdGFseS9zZXJ2aWNlL2RpZmYucHk= 100644
--- a/hgitaly/service/diff.py
+++ b/hgitaly/service/diff.py
@@ -213,4 +213,5 @@
         # For explicitness, let's instantiate a new BytesIO obj for each file
         self.curr_diff.patch = BytesIO()
         for diffhunk in iter_file_hunks:
+            self.curr_diff.patch.write(diffhunk)
             if diffhunk.startswith(b'@@'):
@@ -216,8 +217,7 @@
             if diffhunk.startswith(b'@@'):
-                newdiffhunk = diffhunk.split(b'\n', 1)[-1]
-            lines = newdiffhunk.splitlines(True)
-            self.curr_diff.patch.write(diffhunk)
-            self.curr_diff.bytes_count += len(newdiffhunk)
+                diffhunk = diffhunk.split(b'\n', 1)[-1]
+            lines = diffhunk.splitlines(True)
+            self.curr_diff.bytes_count += len(diffhunk)
             self.curr_diff.line_count += len(lines)
 
         if self.limits.collapse_diffs: