+2011-03-10 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
+
+ Reviewed by Adam Roben.
+
+ PrettyPatch displays last two lines of a git-format-patch diff strangely
+ https://bugs.webkit.org/show_bug.cgi?id=29317
+
+ If the diff section has full range information, we parse only enough to cover the
+ range. This avoids incorrectly showing trailing lines (like git signature) as part
+ of the patch.
+
+ * PrettyPatch/PrettyPatch.rb:
+
2011-03-10 Adam Roben <aroben@apple.com>
Don't search for intra-line diffs in really long lines
START_OF_BINARY_DATA_FORMAT = /^[0-9a-zA-Z\+\/=]{20,}/ # Assume 20 chars without a space is base64 binary data.
- START_OF_SECTION_FORMAT = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@\s*(.*)/
+ START_OF_SECTION_FORMAT = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@\s*(.*)/
START_OF_EXTENT_STRING = "%c" % 0
END_OF_EXTENT_STRING = "%c" % 1
lines.length >= 1 or raise "DiffSection.parse only received %d lines" % lines.length
matches = START_OF_SECTION_FORMAT.match(lines[0])
- from, to = [matches[1].to_i, matches[2].to_i] unless matches.nil?
+
+ if matches
+ from, to = [matches[1].to_i, matches[3].to_i]
+ if matches[2] and matches[4]
+ from_end = from + matches[2].to_i
+ to_end = to + matches[4].to_i
+ end
+ end
@blocks = []
diff_block = nil
from += 1 unless from.nil?
to += 1 unless to.nil?
end
+
+ break if from_end and to_end and from == from_end and to == to_end
end
changes = [ [ [], [] ] ]
end
end
- @blocks.unshift(ContextLine.new(matches[3])) unless matches.nil? || matches[3].empty?
+ @blocks.unshift(ContextLine.new(matches[5])) unless matches.nil? || matches[5].empty?
end
def to_html