git: dfdc3b2e6541 - stable/13 - patch: omit filename if the prompt was ignored

From: Kyle Evans <>
Date: Thu, 16 Feb 2023 03:34:49 UTC
The branch stable/13 has been updated by kevans:


commit dfdc3b2e6541c941b51edd5e5ec575411e5be143
Author:     Kyle Evans <>
AuthorDate: 2023-01-24 16:46:01 +0000
Commit:     Kyle Evans <>
CommitDate: 2023-02-16 03:29:40 +0000

    patch: omit filename if the prompt was ignored
    When a file is missing, patch(1) will prompt for a filename to try and
    patch it.  If we're doing a dry-run, we'll output that the patch to the
    source file was either ignored/failed.  If you ignore the prompt in a
    dry-run (i.e. just hit enter), we'll output:
    X out of X hunks ignored while patching (null)
    Let's improve the aesthetics a bit and just omit the last part if the
    prompt was ignored:
    X out of X hunks ignored
    Unfortunately we can't really test this without expect(1) because both
    force and batch mode will use the first best guess, which is wiped out
    by the "File to patch:" prompt.  We could record the initially derived
    bestguess there and use *that*, but given that this is only possible in
    an interactive session I think it's fine to just omit the filename
    rather than adding a fair amount of complexity (which could also break
    other scenarios I haven't considered yet)..
    Reviewed by:    des
    Sponsored by:   Klara, Inc.
    (cherry picked from commit 7e688ed493482c5346d969e7667856d8ced8d87a)
 usr.bin/patch/patch.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index a23fc82d3d90..48d3bd37fe5b 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -463,9 +463,13 @@ main(int argc, char *argv[])
 			if (!check_only)
 				say("%d out of %d hunks %s--saving rejects to %s\n",
 				    failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname);
-			else
+			else if (filearg[0] != NULL)
 				say("%d out of %d hunks %s while patching %s\n",
 				    failed, hunk, skip_rest_of_patch ? "ignored" : "failed", filearg[0]);
+			else
+				/* File prompt ignored, just note # hunks. */
+				say("%d out of %d hunks %s\n",
+				    failed, hunk, skip_rest_of_patch ? "ignored" : "failed");
 			if (!check_only && move_file(TMPREJNAME, rejname) < 0)
 				trejkeep = true;