[Patchew-devel] [PATCH] series-diff: tweak replacement of ignored text

Paolo Bonzini posted 1 patch 5 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180406095136.15083-2-pbonzini@redhat.com
mods/diff.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[Patchew-devel] [PATCH] series-diff: tweak replacement of ignored text
Posted by Paolo Bonzini 5 years, 11 months ago
Sometimes the "@@" lines end without a function name.  In that case there is no
space after the second "@@".  Tweak the regular expression to cover that case,
checking for end-of-line as an alternative to the space.  For consistency,
anchor the regexes to the beginning of the line as well.
---
 mods/diff.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mods/diff.py b/mods/diff.py
index 197e31e..4896f41 100644
--- a/mods/diff.py
+++ b/mods/diff.py
@@ -77,10 +77,10 @@ class DiffModule(PatchewModule):
             filtered = ""
             sep = ""
             for l in m.get_body().splitlines():
-                for pat, repl in [(r"index [0-9a-f]+\.\.[0-9a-f]+",
+                for pat, repl in [(r"^index [0-9a-f]+\.\.[0-9a-f]+",
                                    r"index XXXXXXX..XXXXXXX"),
-                                  (r"@@ -[0-9]+,[0-9]+ \+[0-9]+,[0-9]+ @@ ",
-                                   r"@@ -XXX,XX +XXX,XX @@ ")]:
+                                   (r"^@@ -[0-9]+,[0-9]+ \+[0-9]+,[0-9]+ @@( |$)",
+                                   r"@@ -XXX,XX +XXX,XX @@\1")]:
                     l = re.sub(pat, repl, l)
                 filtered += sep + l
                 sep = "\n"
-- 
2.16.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel