diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | src/patch.c | 3 | ||||
-rw-r--r-- | tests/create-delete | 26 |
3 files changed, 27 insertions, 6 deletions
@@ -1,6 +1,6 @@ * Two critical bug fixes in the "diff --git" format support. -* Only expect files to become empty if the patch says so (the "other" file - must be /dev/null or dated the Epoch). +* Clarify the message printed when a patch is expected to empty out and delete + a file, but the file does not become empty. * Various improvements to messages when applying a patch to a file of different type (regular file vs. symlink), when there are line ending differences (LF vs. CRLF), and when in --dry-run mode. diff --git a/src/patch.c b/src/patch.c index 7ca7564..828943b 100644 --- a/src/patch.c +++ b/src/patch.c @@ -513,12 +513,13 @@ main (int argc, char **argv) { if (! outstate.zero_output && pch_says_nonexistent (! reverse) == 2 + && (remove_empty_files || ! posixly_correct) && ! (merge && somefailed)) { mismatch = true; somefailed = true; if (verbosity != SILENT) - say ("File %s is not empty after patch, as expected\n", + say ("File %s is not empty after patch; not deleting\n", quotearg (outname)); } diff --git a/tests/create-delete b/tests/create-delete index 54dd920..654246d 100644 --- a/tests/create-delete +++ b/tests/create-delete @@ -182,7 +182,7 @@ EOF check 'patch -p0 -b < p.diff || echo status: $?' <<EOF patching file target -File target is not empty after patch, as expected +File target is not empty after patch; not deleting status: 1 EOF @@ -208,7 +208,7 @@ EOF check 'patch -p0 < p.diff || echo status: $?' <<EOF patching file target -File target is not empty after patch, as expected +File target is not empty after patch; not deleting status: 1 EOF @@ -227,7 +227,7 @@ EOF check 'patch -p1 < p.diff || echo status: $?' <<EOF patching file target -File target is not empty after patch, as expected +File target is not empty after patch; not deleting status: 1 EOF @@ -251,6 +251,13 @@ EOF check 'cat target' <<EOF EOF +echo 1 > target +check 'patch -p0 -E < p.diff || echo status: $?' <<EOF +patching file target +EOF + +ncheck 'test ! -e target' + # ================================================================ # File expected to become empty does become empty @@ -274,3 +281,16 @@ ncheck 'test ! -e target' check 'cat target.orig' <<EOF data EOF + +echo data > target + +check 'patch -p1 -b --posix -f < p.diff || echo status: $?' <<EOF +patching file target +EOF + +check 'cat target' <<EOF +EOF + +check 'cat target.orig' <<EOF +data +EOF |