diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2010-05-02 11:34:24 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2010-05-02 12:40:35 +0200 |
commit | cabd1add5753f9c5479011383e844a9ee93b387b (patch) | |
tree | 0159d76a7eb3cadedd72345631ddec0fcc509a3f /tests | |
parent | 9e39d9c9950076e319d1dbbeeb7b8bd268b465f3 (diff) | |
download | patch-cabd1add5753f9c5479011383e844a9ee93b387b.tar.gz |
Refuse to patch read-only files
* src/patch.c (main): Refuse to patch read-only files, or at least warn
when patching such files with --force or --batch.
* patch.man: Document the changed behavior.
* tests/read-only-files: Split read-only file test case off from
tests/remember-backup-files.
* tests/Makefile.am: Add new test case.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/read-only-files | 48 | ||||
-rw-r--r-- | tests/remember-backup-files | 26 |
3 files changed, 49 insertions, 26 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 3498cc1..39af751 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -37,6 +37,7 @@ TESTS = \ preserve-c-function-names \ preserve-mode-and-timestamp \ quoted-filenames \ + read-only-files \ reject-format \ remember-backup-files \ remember-reject-files \ diff --git a/tests/read-only-files b/tests/read-only-files new file mode 100644 index 0000000..816baab --- /dev/null +++ b/tests/read-only-files @@ -0,0 +1,48 @@ +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# Copying and distribution of this file, with or without modification, +# in any medium, are permitted without royalty provided the copyright +# notice and this notice are preserved. + +# Patching read-only files + +. $srcdir/test-lib.sh + +require_cat +use_local_patch +use_tmpdir + +# ============================================================== + +cat > f.diff <<EOF +--- f.orig ++++ f +@@ -1 +1 @@ +-one ++two +--- f.orig ++++ f +@@ -1 +1 @@ +-two ++three +EOF + +echo one > f +chmod a=r f + +check 'patch -p0 < f.diff || echo "Status: $?"' <<EOF +File f is read-only; refusing to patch +1 out of 1 hunk ignored -- saving rejects to file f.rej +File f is read-only; refusing to patch +1 out of 1 hunk ignored -- saving rejects to file f.rej +Status: 1 +EOF + +rm -f f.rej + +check 'patch -f -p0 < f.diff || echo "Status: $?"' <<EOF +File f is read-only; trying to patch anyway +patching file f +File f is read-only; trying to patch anyway +patching file f +EOF diff --git a/tests/remember-backup-files b/tests/remember-backup-files index 86aafa3..b475d2f 100644 --- a/tests/remember-backup-files +++ b/tests/remember-backup-files @@ -82,29 +82,3 @@ EOF check 'cat g.orig' <<EOF one EOF - -# ============================================================== - -# This test case failed with a permission denied error with a -# previous version of the remember-backup-files patch. - -cat > f.diff <<EOF ---- f.orig -+++ f -@@ -1 +1 @@ --one -+two ---- f.orig -+++ f -@@ -1 +1 @@ --two -+three -EOF - -echo one > f -chmod a=r f - -check 'patch -p0 < f.diff' <<EOF -patching file f -patching file f -EOF |