diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index c56874af2b829f1733fe124d1e5302d70ea73f18..a750e4959010d62b03929147b27e5aaf03c15438 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -53,11 +53,13 @@ module CommitsHelper
 
     lines_arr = diff_arr
     lines_arr.each do |line|
+      next if line.match(/^\-\-\- \/dev\/null/)
+      next if line.match(/^\+\+\+ \/dev\/null/)
+      next if line.match(/^\-\-\- a/)
+      next if line.match(/^\+\+\+ b/)
+
       full_line = html_escape(line.gsub(/\n/, ''))
 
-      next if line.match(/^--- \/dev\/null/)
-      next if line.match(/^--- a/)
-      next if line.match(/^\+\+\+ b/)
       if line.match(/^@@ -/)
         next if line_old == 1 && line_new == 1
         type = "match"
diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml
index 8f65afcd02ce0494c2f76611d8d71954c921017f..e3aa45d6344050e580f863f531ded0487d06fdce 100644
--- a/app/views/commits/_diffs.html.haml
+++ b/app/views/commits/_diffs.html.haml
@@ -4,11 +4,12 @@
 - diffs.each_with_index do |diff, i|
   - next if diff.diff.empty?
   - file = (@commit.tree / diff.b_path)
+  - file = (@commit.prev_commit.tree / diff.a_path) unless file
   - next unless file
   .diff_file
     .diff_file_header
       - if diff.deleted_file
-        %strong{:id => "#{diff.b_path}"}= diff.a_path
+        %strong{:id => "#{diff.a_path}"}= diff.a_path
       - else
         = link_to tree_file_project_ref_path(@project, @commit.id, diff.b_path) do
           %strong{:id => "#{diff.b_path}"}= diff.b_path