diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2012-04-17 16:13:08 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@linbit.com> | 2012-04-17 16:48:19 +0200 |
commit | 9a26fde226660a628d58ed7d987a71b9a4123244 (patch) | |
tree | f19871a06ea2300e4e170a383733a91715f8dac2 /tests | |
parent | b9a1ff0cfa3144f212b4f1c3923c3b3c281e2240 (diff) | |
download | patch-9a26fde226660a628d58ed7d987a71b9a4123244.tar.gz |
Only warn when trying to modify read-only files
Failing when trying to patch read-only files causes various users of patch to
break. Instead, warn by default and introduce a command line option for
choosing a different behavior.
* patch.man: Describe the new behavior and command-line option.
* src/patch.c (read_only_behavior): New variable.
(main): Implement the new behavior.
(longopts): Add the new --read-only option.
(option_help): Describe the new behavior.
(get_some_switches): Recognize the new --read-only option.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/read-only-files | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/read-only-files b/tests/read-only-files index 7db401b..918b97a 100644 --- a/tests/read-only-files +++ b/tests/read-only-files @@ -41,7 +41,7 @@ EOF echo one > f chmod a=r f -check 'patch -p0 < f.diff || echo "Status: $?"' <<EOF +check 'patch -p0 --read-only=fail < 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 @@ -51,9 +51,18 @@ EOF rm -f f.rej -check 'patch -f -p0 < f.diff || echo "Status: $?"' <<EOF +check 'patch -f -p0 --read-only=warn < 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 + +rm -f f +echo one > f +chmod a=r f + +check 'patch -f -p0 --read-only=ignore < f.diff || echo "Status: $?"' <<EOF +patching file f +patching file f +EOF |