quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] patches: Use filenames_in_patch


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] patches: Use filenames_in_patch
Date: Wed, 25 Jun 2014 15:25:03 +0200

Function filenames_in_patch in patchfns does roughly the same as
function touched_by_patch, so fix the former and use it.
---
 quilt/patches.in          |   27 ++-------------------------
 quilt/scripts/patchfns.in |    6 +++++-
 2 files changed, 7 insertions(+), 26 deletions(-)

--- a/quilt/patches.in
+++ b/quilt/patches.in
@@ -60,30 +60,10 @@ scan_applied()
        done
 }
 
-# Note that we can only guess which files a patch touches because of the
-# complicated heuristics that patch uses (see "Multiple Patches in a File"
-# in the diff info pages).
-
-touched_by_patch()
-{
-       local strip=$1 patch=$2
-       cat_file $(patch_file_name $patch) \
-       |  awk '
-       /^(\+\+\+|---)[ \t]/ {
-               sub(/^(\+\+\+|---)[ \t]/, "")
-               sub(/\t[^\t]*$/, "")
-               sub(/^\/dev\/null/, "")
-               for (i=0; i<'$strip'; i++)
-                       sub(/^[^\/]*\//, "")
-               if ($0 != "")
-                       print
-       }'
-}
-
 # Uses global variable opt_files
 scan_unapplied()
 {
-       local color=$1 prefix=$2 strip
+       local color=$1 prefix=$2
        shift 2
        local patch file
        local -a files_bre
@@ -99,10 +79,7 @@ scan_unapplied()
 
        for patch in "$@"
        do
-               strip=$(patch_strip_level $patch)
-               [ "$strip" = ab ] && strip=1
-
-               if touched_by_patch $strip "$patch" \
+               if filenames_in_patch "$patch" \
                   | grep -q "^$file\$"
                then
                        echo "$color$prefix$(print_patch $patch)$color_clear"
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -643,6 +643,9 @@ files_in_patch()
        fi
 }
 
+# Note that we can only guess which files a patch touches because of the
+# complicated heuristics that patch uses (see "Multiple Patches in a File"
+# in the diff info pages).
 filenames_in_patch()
 {
        local patch=$1
@@ -655,7 +658,8 @@ filenames_in_patch()
                ($1 == "+++" || $1 == "---" || $1 == "***") && \
                $3 != "----" && $3 != "****" \
                        { sub(/\t.*/, "")
-                         sub(/^... /, "")
+                         if (sub(/^... /, "") == 0 || $0 == "" || $0 == 
"/dev/null")
+                               next
                          for (n=0 ; n<'$strip'; n++)
                              sub(/^[^\/]+\//, "")
                          print $0 }' $patch_file

-- 
Jean Delvare
SUSE L3 Support




reply via email to

[Prev in Thread] Current Thread [Next in Thread]