diff --git a/app/models/commit.rb b/app/models/commit.rb
index ee16bf084de10ce52caa74c5dfc762a23263e96f..f11b7fe0202eca8a5d2e24f69adb99208a90bdbd 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -159,6 +159,8 @@ class Commit
     while !lines.first.start_with?("diff --git") do
       lines.shift
     end
+    lines.pop if lines.last =~ /^[\d.]+$/ # Git version
+    lines.pop if lines.last == "-- "      # end of diff
     lines.join("\n")
   end
 end