summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-06-14 18:26:34 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-06-14 18:26:34 +0000
commit2d8b6158facc43ebf3143077d834c8516f59c677 (patch)
tree18f9cdddd458a18efb199f8cbede1bee7ef3174d /usr.bin
parent5e21abf53cce0483c922bde7b7bac402ca6ad5c4 (diff)
Teach patch(1) to detect if a diff creating a file (or one adding
lines to an empty file) already has been applied; be a bit less chatty about empty contexts. Testing hshoexer@ ok millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/patch/patch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index a7bfa36960f..3efbd92a809 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.38 2003/10/31 20:20:45 millert Exp $ */
+/* $OpenBSD: patch.c,v 1.39 2004/06/14 18:26:33 otto Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: patch.c,v 1.38 2003/10/31 20:20:45 millert Exp $";
+static const char rcsid[] = "$OpenBSD: patch.c,v 1.39 2004/06/14 18:26:33 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -624,13 +624,13 @@ locate_hunk(LINENUM fuzz)
LINENUM max_neg_offset = first_guess - last_frozen_line - 1 + pch_context();
if (pat_lines == 0) { /* null range matches always */
- if (verbose && (diff_type == CONTEXT_DIFF
+ if (verbose && fuzz == 0 && (diff_type == CONTEXT_DIFF
|| diff_type == NEW_CONTEXT_DIFF
|| diff_type == UNI_DIFF)) {
say("Empty context always matches.\n");
- say("Detection of previously applied patch not possible.\n");
}
- return first_guess;
+ if (fuzz == 0)
+ return (input_lines == 0 ? first_guess : 0);
}
if (max_neg_offset >= first_guess) /* do not try lines < 0 */
max_neg_offset = first_guess - 1;