quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 1/2] refresh: Break links to read-only patch files


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 1/2] refresh: Break links to read-only patch files
Date: Wed, 18 Feb 2015 14:24:44 +0100

We just changed the behavior of the refresh command to no longer
break symbolic links. While preserving the links is the right thing
to do in the general case, this approach fails if the patch file is
read-only. In that case we want to replace the link itself with the
refreshed patch, as we used to.
---
 quilt/scripts/patchfns.in |    5 +++-
 test/symlink.test         |   48 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -785,7 +785,10 @@ cat_to_new_file()
 {
        local filename="$1"
 
-       if [ -e "$filename" -a ! -L "$filename" ]
+       # If the destination file is a symbolic link, preserve it unless its
+       # target is read-only. In other cases, delete the patch file first in
+       # case it has hard links.
+       if [ -e "$filename" -a ! \( -L "$filename" -a -w "$filename" \) ]
        then
                rm -f "$filename"
        fi
--- a/test/symlink.test
+++ b/test/symlink.test
@@ -51,3 +51,51 @@
        > @@ -1 +1 @@
        > -foo
        > +foo changed 2
+
+# Test the refresh when target is read-only
+       $ chmod -w test.diff
+       $ echo "foo changed 4" > foo
+       $ quilt refresh --no-index -p ab
+       > Refreshed patch patches/test.diff
+
+       $ readlink patches/test.diff
+       $ echo %{?}
+       > 1
+
+       $ cat patches/test.diff
+       > --- a/foo
+       > +++ b/foo
+       > @@ -1 +1 @@
+       > -foo
+       > +foo changed 4
+
+# Test the refresh --backup when target is read-only
+       $ mv patches/test.diff .
+       $ ln -s ../test.diff patches/test.diff
+       $ chmod -w test.diff
+
+       $ echo "foo changed 5" > foo
+       $ quilt refresh --backup --no-index -p ab
+       > Refreshed patch patches/test.diff
+
+       $ readlink patches/test.diff
+       $ echo %{?}
+       > 1
+
+       $ cat patches/test.diff
+       > --- a/foo
+       > +++ b/foo
+       > @@ -1 +1 @@
+       > -foo
+       > +foo changed 5
+
+       $ readlink patches/test.diff~
+       $ echo %{?}
+       > 1
+
+       $ cat patches/test.diff~
+       > --- a/foo
+       > +++ b/foo
+       > @@ -1 +1 @@
+       > -foo
+       > +foo changed 4

-- 
Jean Delvare
SUSE L3 Support




reply via email to

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