diff options
-rw-r--r-- | quilt/refresh.in | 7 | ||||
-rw-r--r-- | quilt/scripts/patchfns.in | 5 | ||||
-rw-r--r-- | test/symlink.test | 53 |
3 files changed, 63 insertions, 2 deletions
diff --git a/quilt/refresh.in b/quilt/refresh.in index 41d43a7..b7c7e55 100644 --- a/quilt/refresh.in +++ b/quilt/refresh.in @@ -324,7 +324,12 @@ if [ -e "$patch_file" ] && \ then printf $"Patch %s is unchanged\n" "$(print_patch "$patch")" elif ( [ -z "$QUILT_BACKUP" -o ! -e "$patch_file" ] || \ - mv "$patch_file" "$patch_file~" ) && \ + if [ -L "$patch_file" ] ; \ + then \ + cp "$patch_file" "$patch_file~"; \ + else \ + mv "$patch_file" "$patch_file~"; \ + fi ) && \ cat_to_new_file "$patch_file" < $tmp_result then if [ -n "$opt_fork" ] diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index 3fa26bb..f7100b7 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -785,7 +785,10 @@ cat_to_new_file() { local filename="$1" - [ -e "$filename" ] && rm -f "$filename" + if [ -e "$filename" -a ! -L "$filename" ] + then + rm -f "$filename" + fi case "$filename" in *.gz) diff --git a/test/symlink.test b/test/symlink.test new file mode 100644 index 0000000..9e5e797 --- /dev/null +++ b/test/symlink.test @@ -0,0 +1,53 @@ + $ mkdir patches + +# quilt should not remove symlinks to patch files + $ echo foo > foo + $ quilt new test.diff + > Patch patches/test.diff is now on top + + $ quilt add foo + > File foo added to patch patches/test.diff + + $ echo "foo changed" > foo + $ quilt refresh + > Refreshed patch patches/test.diff + +# Setup a symlink + $ mv patches/test.diff . + $ ln -s ../test.diff patches/test.diff + $ readlink patches/test.diff + > ../test.diff + +# Test the refresh + $ echo "foo changed 2" > foo + $ quilt refresh --no-index -p ab + > Refreshed patch patches/test.diff + + $ readlink patches/test.diff + > ../test.diff + +# Test the refresh --backup + $ echo "foo changed 3" > foo + $ quilt refresh --backup --no-index -p ab + > Refreshed patch patches/test.diff + + $ readlink patches/test.diff + > ../test.diff + + $ cat patches/test.diff + > --- a/foo + > +++ b/foo + > @@ -1 +1 @@ + > -foo + > +foo changed 3 + + $ readlink patches/test.diff~ + $ echo %{?} + > 1 + + $ cat patches/test.diff~ + > --- a/foo + > +++ b/foo + > @@ -1 +1 @@ + > -foo + > +foo changed 2 |