quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH] diff: Workaround bash bug


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] diff: Workaround bash bug
Date: Fri, 28 Feb 2014 16:23:30 +0100

Old versions of bash (at least version 3.2.51) don't properly handle
prefix stripping together with quoting when evaluating an array. So
strip the prefix before adding each file to opt_files. It's faster
anyway.

Same thing when diffing against a snapshot, strip the snapshot
directory prefix from file names before evaluating the quoted files
array.

This fixes a regression introduced in:

commit b0baeeb6b61132af92fd75df5f912554d295dee1
Author: Jean Delvare <address@hidden>
Date:   Fri Mar 25 18:48:49 2011 +0100

    diff, refresh: Accept file names with spaces

(Only affecting the versions of bash which have the aforementioned bug.)

This also fixes a bug when called from a subdirectory and a file
passed as an argument starts with "./".

Extend the test suite to test both cases, so that such bugs can't
sneak in in the future.
---
 quilt/diff.in    |   10 ++++++----
 test/subdir.test |   17 +++++++++++++++++
 test/three.test  |   16 ++++++++++++++++
 3 files changed, 39 insertions(+), 4 deletions(-)

--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -219,7 +219,7 @@ done
 
 QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_format"
 
-opt_files=( $(for file in "$@"; do echo "$SUBDIR$file" ; done) )
+opt_files=( $(for file in "$@"; do echo "$SUBDIR${file#./}" ; done) )
 
 if [ $[0$opt_combine + 0$opt_snapshot + 0$opt_relative] -gt 1 ]
 then
@@ -259,8 +259,10 @@ if [ -n "$opt_snapshot" -a ${#opt_files[
 then
        # Add all files in the snapshot into the file list (they may all
        # have changed).
-       files=( $(find $QUILT_PC/$snap_subdir -type f | sort) )
-       printf "%s\n" "address@hidden/$snap_subdir/}" >&4
+       files=( $(find $QUILT_PC/$snap_subdir -type f \
+                 | sed -e "s/^$(quote_bre $QUILT_PC/$snap_subdir/)//" \
+                 | sort) )
+       printf "%s\n" "address@hidden" >&4
        unset files
        # Also look at all patches that are currently applied.
        opt_combine=1
@@ -298,7 +300,7 @@ do
        for file in $(files_in_patch_ordered "$patch")
        do
                if [ address@hidden -gt 0 ] && \
-                  ! in_array "$file" "address@hidden/}"
+                  ! in_array "$file" "address@hidden"
                then
                        continue
                fi
--- a/test/subdir.test
+++ b/test/subdir.test
@@ -58,5 +58,22 @@
        > @@ -1 +0,0 @@
        > -yet another file
 
+       $ quilt diff --no-index -p ab file file2 no
+       > --- a/subdir/file
+       > +++ b/subdir/file
+       > @@ -1 +1 @@
+       > -old file
+       > +new contents
+       > --- /dev/null
+       > +++ b/subdir/file2
+       > @@ -0,0 +1 @@
+       > +another file
+
+       $ quilt diff --no-index -p ab ./file3 ./no
+       > --- a/subdir/file3
+       > +++ /dev/null
+       > @@ -1 +0,0 @@
+       > -yet another file
+
        $ quilt refresh
        > Refreshed patch %{_P}test.patch
--- a/test/three.test
+++ b/test/three.test
@@ -61,6 +61,22 @@
        $ quilt refresh
        > Refreshed patch %{P}patch2.diff
 
+       $ quilt diff -p0 f g
+       > Index: g
+       > ===================================================================
+       > --- /dev/null
+       > +++ g
+       > @@ -0,0 +1 @@
+       > +g
+
+       $ quilt diff -p0 ./f ./g
+       > Index: g
+       > ===================================================================
+       > --- /dev/null
+       > +++ g
+       > @@ -0,0 +1 @@
+       > +g
+
        $ quilt pop
        > Removing patch patches/patch2.diff
        > Removing g

-- 
Jean Delvare
Suse L3 Support




reply via email to

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