From fc91b4a5ccc18f4eb522a7eecdc5b85a5f04ce6d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 19 Mar 2015 13:47:09 +0100 Subject: Let cat_to_new_file handle the file backup Let function cat_to_new_file optionally backup the destination file before overwriting it. This has two advantages: * This avoids duplicating code on the caller's side. Functions header and refresh both need to perform a backup. * This guarantees the consistency of the backup logic. At the moment, the refresh command would handle the backup of a symlinked file just fine while the header command would misbehave in that case. Now that the header command handles symlinked patches properly, also test it so that we don't break it accidentally later. --- test/symlink.test | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test') diff --git a/test/symlink.test b/test/symlink.test index a9fa45a..342ec10 100644 --- a/test/symlink.test +++ b/test/symlink.test @@ -55,6 +55,43 @@ $ [ patches/test.diff~ -nt test.timeref ] && echo "mtimes differ" +# Test the header update + $ quilt header -a + < A test patch + > Appended text to header of patch patches/test.diff + + $ readlink patches/test.diff + > ../test.diff + +# Test the header update with a backup + $ touch -r patches/test.diff test.timeref + $ quilt header -r --backup + > Replaced header of 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 test patch + > --- a/foo + > +++ b/foo + > @@ -1 +1 @@ + > -foo + > +foo changed 3 + + $ [ patches/test.diff~ -nt test.timeref ] && echo "mtimes differ" + # Test the refresh when target is read-only $ chmod -w test.diff $ echo "foo changed 4" > foo -- cgit