summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-09-26 18:00:45 +0000
committerdelphij <delphij@FreeBSD.org>2013-09-26 18:00:45 +0000
commitce5f424576ec3324fb23f4605341d38da946f21d (patch)
tree2f3c57613b76e480dbb18bf5e09f8dc6436e7653 /usr.bin
parentde2d546a38d24abf8a4cd30b11d6e4cda586f539 (diff)
downloadFreeBSD-src-ce5f424576ec3324fb23f4605341d38da946f21d.zip
FreeBSD-src-ce5f424576ec3324fb23f4605341d38da946f21d.tar.gz
Improve bsdpatch usability:
- Ask only once for "Apply anyway". [1] - Tell user what file have failed patch rather than just how many hunks failed. Reported by: jmg via pfg [1] Tested by: pfg [1] Approved by: re (gjb)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/patch/patch.c11
-rw-r--r--usr.bin/patch/util.c2
2 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 956482c..1743678 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -145,7 +145,7 @@ int
main(int argc, char *argv[])
{
int error = 0, hunk, failed, i, fd;
- bool patch_seen;
+ bool patch_seen, reverse_seen;
LINENUM where = 0, newwhere, fuzz, mymaxfuzz;
const char *tmpdir;
char *v;
@@ -247,6 +247,7 @@ main(int argc, char *argv[])
/* apply each hunk of patch */
hunk = 0;
failed = 0;
+ reverse_seen = false;
out_of_mem = false;
while (another_hunk()) {
hunk++;
@@ -257,7 +258,7 @@ main(int argc, char *argv[])
if (!skip_rest_of_patch) {
do {
where = locate_hunk(fuzz);
- if (hunk == 1 && where == 0 && !force) {
+ if (hunk == 1 && where == 0 && !force && !reverse_seen) {
/* dwim for reversed patch? */
if (!pch_swap()) {
if (fuzz == 0)
@@ -293,6 +294,8 @@ main(int argc, char *argv[])
ask("Apply anyway? [n] ");
if (*buf != 'y')
skip_rest_of_patch = true;
+ else
+ reverse_seen = true;
where = 0;
reverse = !reverse;
if (!pch_swap())
@@ -406,8 +409,8 @@ main(int argc, char *argv[])
say("%d out of %d hunks %s--saving rejects to %s\n",
failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname);
else
- say("%d out of %d hunks %s\n",
- failed, hunk, skip_rest_of_patch ? "ignored" : "failed");
+ say("%d out of %d hunks %s while patching %s\n",
+ failed, hunk, skip_rest_of_patch ? "ignored" : "failed", filearg[0]);
if (!check_only && move_file(TMPREJNAME, rejname) < 0)
trejkeep = true;
}
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index c19918b..6980676 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -412,7 +412,7 @@ checked_in(char *file)
void
version(void)
{
- fprintf(stderr, "patch 2.0-12u9 FreeBSD\n");
+ fprintf(stderr, "patch 2.0-12u10 FreeBSD\n");
my_exit(EXIT_SUCCESS);
}
OpenPOWER on IntegriCloud