summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-07-26 14:32:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-07-26 14:32:20 +0000
commit2afeceaa3106553d69805e23bd0a64225235b2b7 (patch)
tree4b86338a9e623cd3f9d636d8a4f9c705a9d7990b
parent4e62be20ae6433da27e65221c3820094a858f751 (diff)
Remove support for automatically checking files out of RCS. The
behavior is confusing to users and even GNU patch no longer does it by default. OK krw@ guenther@
-rw-r--r--usr.bin/patch/common.h6
-rw-r--r--usr.bin/patch/inp.c67
-rw-r--r--usr.bin/patch/patch.113
-rw-r--r--usr.bin/patch/pch.c38
-rw-r--r--usr.bin/patch/util.c26
-rw-r--r--usr.bin/patch/util.h3
6 files changed, 20 insertions, 133 deletions
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index b20f6b21666..78b9b0d047a 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.h,v 1.28 2014/11/25 10:26:07 tobias Exp $ */
+/* $OpenBSD: common.h,v 1.29 2015/07/26 14:32:19 millert Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -41,10 +41,6 @@
#define BUFFERSIZE 1024
#define LINENUM_MAX LONG_MAX
-#define RCSSUFFIX ",v"
-#define CHECKOUT "co -l %s"
-#define RCSDIFF "rcsdiff %s > /dev/null"
-
#define ORIGEXT ".orig"
#define REJEXT ".rej"
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 1bd7d4c8891..99194a4ac14 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inp.c,v 1.43 2015/02/05 12:59:57 millert Exp $ */
+/* $OpenBSD: inp.c,v 1.44 2015/07/26 14:32:19 millert Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -132,7 +132,7 @@ static bool
plan_a(const char *filename)
{
int ifd, statfailed;
- char *p, *s, lbuf[MAXLINELEN];
+ char *p, *s;
struct stat filestat;
off_t i;
ptrdiff_t sz;
@@ -162,67 +162,8 @@ plan_a(const char *filename)
close(creat(filename, 0666));
statfailed = stat(filename, &filestat);
}
- if (statfailed && check_only)
- fatal("%s not found, -C mode, can't probe further\n", filename);
- /* For nonexistent or read-only files, look for RCS versions. */
- if (statfailed ||
- /* No one can write to it. */
- (filestat.st_mode & 0222) == 0 ||
- /* I can't write to it. */
- ((filestat.st_mode & 0022) == 0 && filestat.st_uid != getuid())) {
- char *cs = NULL, *filebase, *filedir;
- struct stat cstat;
-
- filebase = basename(filename);
- filedir = dirname(filename);
-
- /* Leave room in lbuf for the diff command. */
- s = lbuf + 20;
-
-#define try(f, a1, a2, a3) \
- (snprintf(s, sizeof lbuf - 20, f, a1, a2, a3), stat(s, &cstat) == 0)
-
- if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
- try("%s/RCS/%s%s", filedir, filebase, "") ||
- try("%s/%s%s", filedir, filebase, RCSSUFFIX)) {
- snprintf(buf, sizeof buf, CHECKOUT, filename);
- snprintf(lbuf, sizeof lbuf, RCSDIFF, filename);
- cs = "RCS";
- } else if (statfailed)
- fatal("can't find %s\n", filename);
- /*
- * else we can't write to it but it's not under a version
- * control system, so just proceed.
- */
- if (cs) {
- if (!statfailed) {
- if ((filestat.st_mode & 0222) != 0)
- /* The owner can write to it. */
- fatal("file %s seems to be locked "
- "by somebody else under %s\n",
- filename, cs);
- /*
- * It might be checked out unlocked. See if
- * it's safe to check out the default version
- * locked.
- */
- if (verbose)
- say("Comparing file %s to default "
- "%s version...\n",
- filename, cs);
- if (system(lbuf))
- fatal("can't check out file %s: "
- "differs from default %s version\n",
- filename, cs);
- }
- if (verbose)
- say("Checking out file %s from %s...\n",
- filename, cs);
- if (system(buf) || stat(filename, &filestat))
- fatal("can't check out file %s from %s\n",
- filename, cs);
- }
- }
+ if (statfailed)
+ fatal("can't find %s\n", filename);
filemode = filestat.st_mode;
if (!S_ISREG(filemode))
fatal("%s is not a normal file--can't patch\n", filename);
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1
index 7d8aee1c123..67e51006c4a 100644
--- a/usr.bin/patch/patch.1
+++ b/usr.bin/patch/patch.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: patch.1,v 1.29 2015/03/13 19:58:41 jmc Exp $
+.\" $OpenBSD: patch.1,v 1.30 2015/07/26 14:32:19 millert Exp $
.\" Copyright 1986, Larry Wall
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -19,7 +19,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: March 13 2015 $
+.Dd $Mdocdate: July 26 2015 $
.Dt PATCH 1
.Os
.Sh NAME
@@ -479,15 +479,6 @@ file names or, for a non-context diff, the
file name, and choose the file name with the fewest path components,
the shortest basename, and the shortest total file name length (in that order).
.It
-If no file exists,
-.Nm
-checks for the existence of the files in an RCS directory
-(using the appropriate suffix) using the criteria specified
-above.
-If found,
-.Nm
-will attempt to get or check out the file.
-.It
If no suitable file was found to patch, the patch file is a context or
unified diff, and the old file was zero length, the new file name is
created and used.
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index b3a7345e8d3..36cd608bc5e 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.51 2015/02/05 12:59:57 millert Exp $ */
+/* $OpenBSD: pch.c,v 1.52 2015/07/26 14:32:19 millert Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -1457,17 +1457,8 @@ posix_name(const struct file_name *names, bool assume_exists)
}
if (path == NULL && !assume_exists) {
/*
- * No files found, look for something we can checkout from
- * RCS dirs. Same order as above.
- */
- for (i = 0; i < MAX_FILE; i++) {
- if (names[i].path != NULL &&
- (path = checked_in(names[i].path)) != NULL)
- break;
- }
- /*
- * Still no match? Check to see if the diff could be creating
- * a new file.
+ * No files found, check to see if the diff could be
+ * creating a new file.
*/
if (path == NULL && ok_to_create_file &&
names[NEW_FILE].path != NULL)
@@ -1478,7 +1469,7 @@ posix_name(const struct file_name *names, bool assume_exists)
}
static char *
-compare_names(const struct file_name *names, bool assume_exists, int phase)
+compare_names(const struct file_name *names, bool assume_exists)
{
size_t min_components, min_baselen, min_len, tmp;
char *best = NULL;
@@ -1495,9 +1486,7 @@ compare_names(const struct file_name *names, bool assume_exists, int phase)
min_components = min_baselen = min_len = SIZE_MAX;
for (i = INDEX_FILE; i >= OLD_FILE; i--) {
path = names[i].path;
- if (path == NULL ||
- (phase == 1 && !names[i].exists && !assume_exists) ||
- (phase == 2 && checked_in(path) == NULL))
+ if (path == NULL || (!names[i].exists && !assume_exists))
continue;
if ((tmp = num_components(path)) > min_components)
continue;
@@ -1528,17 +1517,12 @@ best_name(const struct file_name *names, bool assume_exists)
{
char *best;
- best = compare_names(names, assume_exists, 1);
- if (best == NULL) {
- best = compare_names(names, assume_exists, 2);
- /*
- * Still no match? Check to see if the diff could be creating
- * a new file.
- */
- if (best == NULL && ok_to_create_file &&
- names[NEW_FILE].path != NULL)
- best = names[NEW_FILE].path;
- }
+ best = compare_names(names, assume_exists);
+
+ /* No match? Check to see if the diff could be creating a new file. */
+ if (best == NULL && ok_to_create_file)
+ best = names[NEW_FILE].path;
+
return best ? xstrdup(best) : NULL;
}
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index ee6e5d12a9f..f9d47906300 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.39 2015/01/16 06:40:10 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.40 2015/07/26 14:32:19 millert Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -388,30 +388,6 @@ fetchname(const char *at, bool *exists, int strip_leading)
return name;
}
-/*
- * Takes the name returned by fetchname and looks in RCS directory
- * for a checked in version.
- */
-char *
-checked_in(char *file)
-{
- char *filebase, *filedir, tmpbuf[PATH_MAX];
- struct stat filestat;
-
- filebase = basename(file);
- filedir = dirname(file);
-
-#define try(f, a1, a2, a3) \
-(snprintf(tmpbuf, sizeof tmpbuf, f, a1, a2, a3), stat(tmpbuf, &filestat) == 0)
-
- if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
- try("%s/RCS/%s%s", filedir, filebase, "") ||
- try("%s/%s%s", filedir, filebase, RCSSUFFIX))
- return file;
-
- return NULL;
-}
-
void
version(void)
{
diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h
index 5cd0ba84057..6404eb21baf 100644
--- a/usr.bin/patch/util.h
+++ b/usr.bin/patch/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.16 2014/12/13 10:31:07 tobias Exp $ */
+/* $OpenBSD: util.h,v 1.17 2015/07/26 14:32:19 millert Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,6 @@
*/
char *fetchname(const char *, bool *, int);
-char *checked_in(char *);
int backup_file(const char *);
int move_file(const char *, const char *);
int copy_file(const char *, const char *);