Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix a one off error in rename handling for grit diff

  • Loading branch information...
commit e79a0e189f142c2973fbf80337f8c4ff386d3da0 1 parent ff01507
@bkad bkad authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/grit/diff.rb
View
9 lib/grit/diff.rb
@@ -57,11 +57,14 @@ def self.list_from_string(repo, text)
elsif lines.first =~ /^similarity index (\d+)\%/
sim_index = $1.to_i
renamed_file = true
- 2.times { lines.shift } # shift away the 2 `rename from/to ...` lines
+ 3.times { lines.shift } # shift away the similarity index line and the 2 `rename from/to ...` lines
end
- m, a_blob, b_blob, b_mode = *lines.shift.match(%r{^index ([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+) ?(.+)?$})
- b_mode.strip! if b_mode
+ a_blob, b_blob, b_mode = nil, nil, nil
+ if !lines.empty? && lines.first !~ /^diff/
+ m, a_blob, b_blob, b_mode = *lines.shift.match(%r{^index ([0-9A-Fa-f]+)\.\.([0-9A-Fa-f]+) ?(.+)?$})
+ b_mode.strip! if b_mode
+ end
diff_lines = []
while lines.first && lines.first !~ /^diff/
Please sign in to comment.
Something went wrong with that request. Please try again.