HomeFreeBSD

patch: omit filename if the prompt was ignored

Description

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.
Differential Revision: https://reviews.freebsd.org/D38179

Details

Provenance
kevansAuthored on Jan 24 2023, 4:46 PM
Reviewer
des
Differential Revision
D38179: patch: omit filename if the prompt was ignored
Parents
rGe63dcbe7a2cb: wg: tests: remove an obsolete workaround
Branches
Unknown
Tags
Unknown