From: Lars Kurth Date: Thu, 27 Jul 2017 18:29:18 +0000 (+0100) Subject: Fixed issues with thunks by sorting them in normalize_diff() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a702500448aea12a60afd7ea6727feb8ac54bd98;p=people%2Flarsk%2Fxen-release-scripts.git Fixed issues with thunks by sorting them in normalize_diff() --- diff --git a/README b/README index daa6fc9..8e9d126 100644 --- 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* diff --git a/match-xsa b/match-xsa index 9d131d7..67cb0db 100755 --- 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; +}