| |   |
| 33 | 33 | if @commit.parent |
| 34 | 34 | @diff = @git.diff(@commit.parent.sha || "", @commit.sha) |
| 35 | 35 | else |
| 36 | | # initial commit |
| 37 | | @diff = @commit.diff("") # fIXME: diffs are the wrong way |
| 36 | # initial commit, link to the initial tree instead |
| 37 | @diff = nil |
| 38 | 38 | end |
| 39 | 39 | @comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.sha}) |
| 40 | 40 | end |
| toggle raw diff |
--- a/app/controllers/browse_controller.rb
+++ b/app/controllers/browse_controller.rb
@@ -33,8 +33,8 @@ class BrowseController < ApplicationController
if @commit.parent
@diff = @git.diff(@commit.parent.sha || "", @commit.sha)
else
- # initial commit
- @diff = @commit.diff("") # fIXME: diffs are the wrong way
+ # initial commit, link to the initial tree instead
+ @diff = nil
end
@comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.sha})
end |
| |   |
| 14 | 14 | |
| 15 | 15 | <% #TODO: commit diff stats (as sparklines?) -%> |
| 16 | 16 | |
| 17 | | <h2>Commit diff</h2> |
| 18 | | <%= render_diffmode_selector -%> |
| 19 | | |
| 20 | | <% @diff.each do |file| -%> |
| 21 | | <h4><%= h(file.path) -%><%#=link_to h(file.path), blob_path(file.sha, file.path) -%></h4> |
| 22 | | <%= render_diff(file.patch, file.src, file.dst, @diffmode) -%> |
| 23 | | <small><%= link_to_function "toggle raw diff", "$('#{file.object_id}').toggle()" -%></small> |
| 24 | | <div class="toggle_diff" style="display:none" id="<%= file.object_id -%>"> |
| 25 | | <p><pre><%= h(file.patch) -%></pre></p> |
| 26 | | </div> |
| 17 | <% if @diff.blank? -%> |
| 18 | <p> |
| 19 | This is the initial commit in this repository, |
| 20 | <%= link_to "browse the initial tree state", tree_path(@commit.gtree.sha) -%>. |
| 21 | </p> |
| 22 | <% else -%> |
| 23 | <h2>Commit diff</h2> |
| 24 | <%= render_diffmode_selector -%> |
| 25 | |
| 26 | <% @diff.each do |file| -%> |
| 27 | <h4><%= h(file.path) -%><%#=link_to h(file.path), blob_path(file.sha, file.path) -%></h4> |
| 28 | <%= render_diff(file.patch, file.src, file.dst, @diffmode) -%> |
| 29 | <small><%= link_to_function "toggle raw diff", "$('#{file.object_id}').toggle()" -%></small> |
| 30 | <div class="toggle_diff" style="display:none" id="<%= file.object_id -%>"> |
| 31 | <p><pre><%= h(file.patch) -%></pre></p> |
| 32 | </div> |
| 33 | <% end -%> |
| 27 | 34 | <% end -%> |
| 28 | 35 | |
| 29 | 36 | <%= render :partial => "submenu" -%> |
| toggle raw diff |
--- a/app/views/browse/commit.html.erb
+++ b/app/views/browse/commit.html.erb
@@ -14,16 +14,23 @@
<% #TODO: commit diff stats (as sparklines?) -%>
-<h2>Commit diff</h2>
-<%= render_diffmode_selector -%>
-
-<% @diff.each do |file| -%>
- <h4><%= h(file.path) -%><%#=link_to h(file.path), blob_path(file.sha, file.path) -%></h4>
- <%= render_diff(file.patch, file.src, file.dst, @diffmode) -%>
- <small><%= link_to_function "toggle raw diff", "$('#{file.object_id}').toggle()" -%></small>
- <div class="toggle_diff" style="display:none" id="<%= file.object_id -%>">
- <p><pre><%= h(file.patch) -%></pre></p>
- </div>
+<% if @diff.blank? -%>
+ <p>
+ This is the initial commit in this repository,
+ <%= link_to "browse the initial tree state", tree_path(@commit.gtree.sha) -%>.
+ </p>
+<% else -%>
+ <h2>Commit diff</h2>
+ <%= render_diffmode_selector -%>
+
+ <% @diff.each do |file| -%>
+ <h4><%= h(file.path) -%><%#=link_to h(file.path), blob_path(file.sha, file.path) -%></h4>
+ <%= render_diff(file.patch, file.src, file.dst, @diffmode) -%>
+ <small><%= link_to_function "toggle raw diff", "$('#{file.object_id}').toggle()" -%></small>
+ <div class="toggle_diff" style="display:none" id="<%= file.object_id -%>">
+ <p><pre><%= h(file.patch) -%></pre></p>
+ </div>
+ <% end -%>
<% end -%>
<%= render :partial => "submenu" -%>
\ No newline at end of file |