diff options
author | Jean Delvare <jdelvare@suse.de> | 2015-02-25 09:00:17 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2015-02-25 09:00:17 +0100 |
commit | 53aaf3f477dd2d030766fab55d3b14386abe2afa (patch) | |
tree | 556ad7a4f4631f4b72fb8d90460638074cbc5635 | |
parent | 8fe2ce95f77a39ecf7e0fc567534bf2349259e22 (diff) | |
download | quilt-53aaf3f477dd2d030766fab55d3b14386abe2afa.tar.gz |
refresh: Break links to read-only patch files
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.
-rw-r--r-- | quilt/scripts/patchfns.in | 5 | ||||
-rw-r--r-- | test/symlink.test | 48 |
2 files changed, 52 insertions, 1 deletions
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index f7100b7..efb6e8e 100644 --- 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 diff --git a/test/symlink.test b/test/symlink.test index 9e5e797..4610af6 100644 --- 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 |