From 3ccb16e10b7b4312e9b6096760ddc4c2d90194f2 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Tue, 17 Apr 2012 22:37:17 +0200 Subject: Improve messages when in --dry-run mode * src/patch.c (main): Say that we are checking a file and not that we are patching it in --dry-run mode. Don't say "saving rejects to file" when we don't create reject files. * tests/reject-format: Add rejects with --dry-run test case. * tests/bad-filenames, tests/fifo, tests/mixed-patch-types: Update. --- src/patch.c | 7 +++++-- tests/bad-filenames | 8 ++++---- tests/fifo | 8 ++++---- tests/mixed-patch-types | 8 ++++---- tests/reject-format | 7 +++++++ 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/patch.c b/src/patch.c index 97eea5b..f05e542 100644 --- a/src/patch.c +++ b/src/patch.c @@ -345,7 +345,8 @@ main (int argc, char **argv) { bool renamed = strcmp (inname, outname); - say ("patching %s %s%c", + say ("%s %s %s%c", + dry_run ? "checking" : "patching", S_ISLNK (file_type) ? "symbolic link" : "file", quotearg (outname), renamed ? ' ' : '\n'); if (renamed) @@ -602,9 +603,9 @@ main (int argc, char **argv) rej[len - 1] = '#'; simple_backup_suffix = s; } - say (" -- saving rejects to file %s\n", quotearg (rej)); if (! dry_run) { + say (" -- saving rejects to file %s\n", quotearg (rej)); if (rejname) { if (! written_to_rejname) @@ -631,6 +632,8 @@ main (int argc, char **argv) &rejst, rej, S_IFREG | 0666, false); } } + else + say ("\n"); if (!rejname) free (rej); } else diff --git a/tests/bad-filenames b/tests/bad-filenames index 121cfda..be65ca5 100644 --- a/tests/bad-filenames +++ b/tests/bad-filenames @@ -25,7 +25,7 @@ EOF # or that contains a ".." component. check 'emit_patch ../z | patch -f -p1 --dry-run || echo status: $?' < f check 'patch -f -p0 --dry-run < d.diff || echo status: $?' < g check 'patch -f -p1 --dry-run < d.diff || echo status: $?' < f.diff < fifo & check 'patch --dry-run < fifo' < fifo & check 'patch --dry-run -i fifo' < f diff -p -c -L f.orig -L f f.orig f > f.diff +check 'patch -f -F0 --no-backup-if-mismatch --dry-run f < f.diff || echo "Status: $?"' <