From e8bfce654715e443830069b9dfa73e7300de0392 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Wed, 26 Sep 2012 01:33:22 +0200 Subject: Improve the previous commit * src/patch.c: Only print the "file is not empty after patch" message when trying to delete the output file. Say that we were trying to delete the file. * tests/create-delete: Fix the expected messages. Add test cases for the --remove-empty-files and --posix options. * NEWS: Better describe this change. --- NEWS | 4 ++-- src/patch.c | 3 ++- tests/create-delete | 26 +++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 434f21c..3b2dc92 100644 --- a/NEWS +++ b/NEWS @@ -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: $?' < target +check 'patch -p0 -E < p.diff || echo status: $?' < target + +check 'patch -p1 -b --posix -f < p.diff || echo status: $?' <