PrettyPatch.rb doesn't handle diffs where lines matching /^--/ are missing properly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Dec 2013 16:45:11 +0000 (16:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Dec 2013 16:45:11 +0000 (16:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=54928

Patch by Dániel Bátyai <Batyai.Daniel@stud.u-szeged.hu> on 2013-12-16
Reviewed by Adam Roben.

PrettyPatch will now check if the next line after /^--- / matches /^+++ /, and if not,
then it's just a normal line

* PrettyPatch/PrettyPatch.rb:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160642 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/bugs.webkit.org/ChangeLog
Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb

index a3fb1d6..68e55ff 100644 (file)
@@ -1,3 +1,15 @@
+2013-12-16  Dániel Bátyai  <Batyai.Daniel@stud.u-szeged.hu>
+
+        PrettyPatch.rb doesn't handle diffs where lines matching /^--/ are missing properly
+        https://bugs.webkit.org/show_bug.cgi?id=54928
+
+        Reviewed by Adam Roben.
+
+        PrettyPatch will now check if the next line after /^--- / matches /^+++ /, and if not,
+        then it's just a normal line
+
+        * PrettyPatch/PrettyPatch.rb:
+
 2013-08-16  David Farler  <dfarler@apple.com>
 
         PrettyPatch: Wrap pre blocks
index 8f81b86..837dbfa 100644 (file)
@@ -662,11 +662,12 @@ EOF
         def self.parse(string)
             haveSeenDiffHeader = false
             linesForDiffs = []
-            string.each_line do |line|
+            line_array = string.lines.to_a
+            line_array.each_with_index do |line, index|
                 if (PrettyPatch.diff_header?(line))
                     linesForDiffs << []
                     haveSeenDiffHeader = true
-                elsif (!haveSeenDiffHeader && line =~ /^--- /)
+                elsif (!haveSeenDiffHeader && line =~ /^--- / && line_array[index + 1] =~ /^\+\+\+ /)
                     linesForDiffs << []
                     haveSeenDiffHeader = false
                 end