]> xenbits.xensource.com Git - people/larsk/xen-release-scripts.git/commitdiff
Fixed issues with thunks by sorting them in normalize_diff()
authorLars Kurth <lars.kurth@citrix.com>
Thu, 27 Jul 2017 18:29:18 +0000 (19:29 +0100)
committerLars Kurth <lars.kurth@citrix.com>
Thu, 27 Jul 2017 18:29:18 +0000 (19:29 +0100)
README
match-xsa

diff --git a/README b/README
index daa6fc9446fa90e5ee00d52792164c40cf11db15..8e9d1264b01761bfb1da2d7ad7cc38b569aecfc9 100644 (file)
--- a/README
+++ b/README
@@ -186,8 +186,7 @@ TODOS AND OPEN ISSUES
 =====================
 
 *match-xsa*
-* The reporting can probably be improved: aka, highlight blocks with potential issues better. For example, embed relevant portions of an XSA into the output in cases where there is no match 
-* Issue with *--smart*: currently falls over and produces a non-match if the per-file diffs from *git show* and in the *.patch* file are listed in a different order. This seems to happen rarely, but does happen.
+* The reporting can probably be improved: aka, highlight blocks with potential issues better. For example, embed relevant portions of an XSA into the output in cases where there is no match
 * --xsadir currently only works when providing an absolute path (the issue was introduced in commit 6d371d6adccc36eeeb5d2acd412ba0f3424a4a15)
 
 *xsa.git:Infra/xsa-list-patches*
index 9d131d7d77131d4bca3e43f7aa6e42a5ef8a32e6..67cb0db497fcd7f17f08caca2c278c500f6f495f 100755 (executable)
--- a/match-xsa
+++ b/match-xsa
@@ -445,6 +445,8 @@ sub normalize_diff {
           next;
        } elsif (index($lines[$i], "-") == 0) {
           # Only allow "-*", but not "--", "---", etc.
+          # We can throw away "--" and "---" as in git we only
+          # compare different versions of the same file
           if (index($lines[$i], "--") != 0) {
             push @newlines, $lines[$i];       
             next;
@@ -464,7 +466,18 @@ sub normalize_diff {
           push @newlines, "@@";       
           next;
        }
-   }   
-     
-   return join "\n", @newlines;
-}
\ No newline at end of file
+   }
+   
+   # At this point, we have diff chunks neatly identified
+   # by "+++". All we have to do is re-join the lines, split them
+   # into chunks (1 per pseudo-line), sort them, re-assemble.
+   $text = join "\n", @newlines;
+   # Make sure this ends with a newline (otherwise the next
+   # section
+   $text .= "\n";
+    
+   my @plines = split /^\+\+\+ /m, $text;
+   my @newplines = sort @plines;
+       
+   return join "+++ ", @newplines;
+}