From 1f5deb73078c087cbe2e301820d3cdc4e77d3b64 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Fri, 11 Mar 2011 00:05:57 +0000 Subject: [PATCH] 2011-03-10 Caio Marcelo de Oliveira Filho 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: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80782 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Websites/bugs.webkit.org/ChangeLog | 13 +++++++++++++ .../bugs.webkit.org/PrettyPatch/PrettyPatch.rb | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Websites/bugs.webkit.org/ChangeLog b/Websites/bugs.webkit.org/ChangeLog index 8dd2311d53ec..e11beaadc944 100644 --- a/Websites/bugs.webkit.org/ChangeLog +++ b/Websites/bugs.webkit.org/ChangeLog @@ -1,3 +1,16 @@ +2011-03-10 Caio Marcelo de Oliveira Filho + + 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 Don't search for intra-line diffs in really long lines diff --git a/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb b/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb index 8f42ac2f8ed1..2eaf3c14c78a 100644 --- a/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb +++ b/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb @@ -65,7 +65,7 @@ private 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 @@ -670,7 +670,14 @@ END 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 @@ -710,6 +717,8 @@ END 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 = [ [ [], [] ] ] @@ -753,7 +762,7 @@ END 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 -- 2.36.0