diff --git a/app/controllers/projects/git/commits_controller.rb b/app/controllers/projects/git/commits_controller.rb index 123ed40c4..117530638 100644 --- a/app/controllers/projects/git/commits_controller.rb +++ b/app/controllers/projects/git/commits_controller.rb @@ -43,5 +43,6 @@ class Projects::Git::CommitsController < Projects::Git::BaseController params2 #FIXME git has other ref? end @commit = @project.repo.commit(ref) || raise(ActiveRecord::RecordNotFound) + @common_ancestor = @project.repo.commit(@project.repo.git.merge_base({}, @commit1, @commit)) || @commit1 end end diff --git a/app/views/projects/git/commits/_commit_diff.html.haml b/app/views/projects/git/commits/_commit_diff.html.haml index c02a04395..fcb232f2b 100644 --- a/app/views/projects/git/commits/_commit_diff.html.haml +++ b/app/views/projects/git/commits/_commit_diff.html.haml @@ -6,5 +6,6 @@ - if commit_diff.b_path.present? .r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path) .clear - -unless (@project.repo.tree(commit_id) / commit_diff.b_path).binary? + -if commit_diff.diff.present? && !(@project.repo.tree(commit_id) / commit_diff.a_path).binary? + ="a_path=#{commit_diff.a_path}; b_path=#{commit_diff.b_path}" if (@project.repo.tree(commit_id) / commit_diff.b_path).nil? .diff_data=render_diff(commit_diff, :diff_counter => commit_diff_counter, :comments => @comments) diff --git a/app/views/projects/git/commits/diff.html.haml b/app/views/projects/git/commits/diff.html.haml index f3e46be15..30bed9283 100644 --- a/app/views/projects/git/commits/diff.html.haml +++ b/app/views/projects/git/commits/diff.html.haml @@ -1,6 +1,17 @@ -begin =render_diff_stats(@project.repo.diff_stats @commit1.id, @commit.id) = "#{@commit1}...#{@commit}" - =render :partial => 'commit_diff', :collection => @project.repo.diff(@commit1.id, @commit.id) + =#render :partial => 'commit_diff', :collection => @project.repo.diff(@commit1.id, @commit.id) + -@project.repo.diff(@commit1.id, @commit.id).each_with_index do |commit_diff, diff_counter| + - commit_id = commit_diff.deleted_file ? @common_ancestor.id : @commit.id + .file + %a{:name => "diff-#{diff_counter}"} + .top + .l= h(commit_diff.a_path.rtruncate 120) + - if commit_diff.b_path.present? + .r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path) + .clear + -if commit_diff.diff.present? && !(@project.repo.tree(commit_id) / commit_diff.b_path).binary? + .diff_data=render_diff(commit_diff, :diff_counter => diff_counter) - rescue Grit::Git::GitTimeout %p= t 'layout.git.repositories.commit_diff_too_big'