summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/patch
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-02-17 22:16:05 +0000
committerjkh <jkh@FreeBSD.org>1994-02-17 22:16:05 +0000
commit98554d2175a4ee6cf8aaf7b97671e47d05903797 (patch)
tree970a443b301639e7a1278a3fcf23ad5b55c0e657 /gnu/usr.bin/patch
parent6f335eef9c451b24fe3d59f9d883e95b4daee558 (diff)
downloadFreeBSD-src-98554d2175a4ee6cf8aaf7b97671e47d05903797.zip
FreeBSD-src-98554d2175a4ee6cf8aaf7b97671e47d05903797.tar.gz
From Poul-Henning Kamp - Implement a -C option to verify the integrity of
a patch before actually applying it.
Diffstat (limited to 'gnu/usr.bin/patch')
-rw-r--r--gnu/usr.bin/patch/patch.110
-rw-r--r--gnu/usr.bin/patch/patch.c28
-rw-r--r--gnu/usr.bin/patch/pch.c8
3 files changed, 35 insertions, 11 deletions
diff --git a/gnu/usr.bin/patch/patch.1 b/gnu/usr.bin/patch/patch.1
index bf20668..657ef17 100644
--- a/gnu/usr.bin/patch/patch.1
+++ b/gnu/usr.bin/patch/patch.1
@@ -1,8 +1,11 @@
.\" -*- nroff -*-
.rn '' }`
-'\" $Header: patch.man,v 2.0.1.2 88/06/22 20:47:18 lwall Locked $
+'\" $Header: /home/cvs/386BSD/src/gnu/usr.bin/patch/patch.1,v 1.1.1.1 1993/06/19 14:21:51 paul Exp $
'\"
-'\" $Log: patch.man,v $
+'\" $Log: patch.1,v $
+.\" Revision 1.1.1.1 1993/06/19 14:21:51 paul
+.\" b-maked patch-2.10
+.\"
'\" Revision 2.0.1.2 88/06/22 20:47:18 lwall
'\" patch12: now avoids Bell System Logo
'\"
@@ -258,6 +261,9 @@ forces
.I patch
to interpret the patch file as a context diff.
.TP 5
+.B "\-C, \-\-check"
+see what would happen, but don't do it.
+.TP 5
.B "\-d dir, \-\-directory=dir"
causes
.I patch
diff --git a/gnu/usr.bin/patch/patch.c b/gnu/usr.bin/patch/patch.c
index 77d98e7..92755a5 100644
--- a/gnu/usr.bin/patch/patch.c
+++ b/gnu/usr.bin/patch/patch.c
@@ -1,5 +1,5 @@
char rcsid[] =
- "$Header: patch.c,v 2.0.2.0 90/05/01 22:17:50 davison Locked $";
+ "$Header: /home/cvs/386BSD/src/gnu/usr.bin/patch/patch.c,v 1.1.1.1 1993/06/19 14:21:52 paul Exp $";
/* patch - a program to apply diffs to original files
*
@@ -8,7 +8,10 @@ char rcsid[] =
* This program may be copied as long as you don't try to make any
* money off of it, or pretend that you wrote it.
*
- * $Log: patch.c,v $
+ * $Log: patch.c,v $
+ * Revision 1.1.1.1 1993/06/19 14:21:52 paul
+ * b-maked patch-2.10
+ *
* Revision 2.0.2.0 90/05/01 22:17:50 davison
* patch12u: unidiff support added
*
@@ -123,6 +126,9 @@ static int remove_empty_files = FALSE;
/* TRUE if -R was specified on command line. */
static int reverse_flag_specified = FALSE;
+/* TRUE if -C was specified on command line. */
+static int check_patch = FALSE;
+
/* Apply a set of diffs as appropriate. */
int
@@ -352,7 +358,9 @@ char **argv;
struct stat statbuf;
char *realout = outname;
- if (move_file(TMPOUTNAME, outname) < 0) {
+ if (check_patch) {
+ ;
+ } else if (move_file(TMPOUTNAME, outname) < 0) {
toutkeep = TRUE;
realout = TMPOUTNAME;
chmod(TMPOUTNAME, filemode);
@@ -383,7 +391,9 @@ char **argv;
say4("%d out of %d hunks failed--saving rejects to %s\n",
failed, hunk, rejname);
}
- if (move_file(TMPREJNAME, rejname) < 0)
+ if (check_patch) {
+ ;
+ } else if (move_file(TMPREJNAME, rejname) < 0)
trejkeep = TRUE;
}
set_signals(1);
@@ -431,11 +441,12 @@ reinitialize_almost_everything()
fatal1("you may not change to a different patch file\n");
}
-static char *shortopts = "-b:B:cd:D:eEfF:lnNo:p::r:RsStuvV:x:";
+static char *shortopts = "-b:B:cCd:D:eEfF:lnNo:p::r:RsStuvV:x:";
static struct option longopts[] =
{
{"suffix", 1, NULL, 'b'},
{"prefix", 1, NULL, 'B'},
+ {"check", 0, NULL, 'C'},
{"context", 0, NULL, 'c'},
{"directory", 1, NULL, 'd'},
{"ifdef", 1, NULL, 'D'},
@@ -492,6 +503,9 @@ get_some_switches()
case 'c':
diff_type = CONTEXT_DIFF;
break;
+ case 'C':
+ check_patch = TRUE;
+ break;
case 'd':
if (chdir(optarg) < 0)
pfatal2("can't cd to %s", optarg);
@@ -572,9 +586,9 @@ Usage: %s [options] [origfile [patchfile]] [+ [options] [origfile]]...\n",
Argv[0]);
fprintf(stderr, "\
Options:\n\
- [-ceEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
+ [-cCeEflnNRsStuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
[-D symbol] [-F max-fuzz] [-o out-file] [-p[strip-count]]\n\
- [-r rej-name] [-V {numbered,existing,simple}] [--context]\n\
+ [-r rej-name] [-V {numbered,existing,simple}] [--check] [--context]\n\
[--prefix=backup-prefix] [--suffix=backup-ext] [--ifdef=symbol]\n\
[--directory=directory] [--ed] [--fuzz=max-fuzz] [--force] [--batch]\n\
[--ignore-whitespace] [--forward] [--reverse] [--output=out-file]\n");
diff --git a/gnu/usr.bin/patch/pch.c b/gnu/usr.bin/patch/pch.c
index 6b7d77d..343739d 100644
--- a/gnu/usr.bin/patch/pch.c
+++ b/gnu/usr.bin/patch/pch.c
@@ -1,6 +1,9 @@
-/* $Header: pch.c,v 2.0.1.7 88/06/03 15:13:28 lwall Locked $
+/* $Header: /home/cvs/386BSD/src/gnu/usr.bin/patch/pch.c,v 1.1.1.1 1993/06/19 14:21:52 paul Exp $
+ *
+ * $Log: pch.c,v $
+ * Revision 1.1.1.1 1993/06/19 14:21:52 paul
+ * b-maked patch-2.10
*
- * $Log: pch.c,v $
* Revision 2.0.2.0 90/05/01 22:17:51 davison
* patch12u: unidiff support added
*
@@ -177,6 +180,7 @@ there_is_another_patch()
if (force || batch) {
say1("No file to patch. Skipping...\n");
filearg[0] = savestr(bestguess);
+ skip_rest_of_patch = TRUE;
return TRUE;
}
ask1("File to patch: ");
OpenPOWER on IntegriCloud