summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-06-04 09:52:57 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-06-04 09:52:57 +0000
commit11a4c991c440ae69f9165493223c22d1e8512597 (patch)
tree9699800b9ad5d75c0dc7771ad24dc64cde04cc2c /usr.bin/cvs
parent66ef516e5404c5db094b9fa2607166e65bd43556 (diff)
sprinkle -n voodoo over the add, commit and import commands.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/add.c41
-rw-r--r--usr.bin/cvs/commit.c5
-rw-r--r--usr.bin/cvs/import.c46
-rw-r--r--usr.bin/cvs/rcs.c5
4 files changed, 64 insertions, 33 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 4cea0ab5246..451a37dadf3 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.52 2006/06/01 20:00:52 joris Exp $ */
+/* $OpenBSD: add.c,v 1.53 2006/06/04 09:52:56 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -104,7 +104,7 @@ cvs_add_local(struct cvs_file *cf)
static void
add_directory(struct cvs_file *cf)
{
- int l;
+ int l, added;
struct stat st;
CVSENTRIES *entlist;
char *entry, *repo;
@@ -116,10 +116,12 @@ add_directory(struct cvs_file *cf)
if (l == -1 || l >= MAXPATHLEN)
fatal("cvs_add_local: overflow");
+ added = 1;
if (stat(entry, &st) != -1) {
cvs_log(LP_NOTICE, "cannot add directory %s: "
"a file with that name already exists",
cf->file_path);
+ added = 0;
} else {
l = snprintf(entry, MAXPATHLEN, "%s/%s", cf->file_path,
CVS_PATH_CVSDIR);
@@ -134,7 +136,8 @@ add_directory(struct cvs_file *cf)
cvs_log(LP_NOTICE, "%s already exists",
entry);
}
- } else {
+ added = 0;
+ } else if (cvs_noexec != 1) {
if (mkdir(cf->file_rpath, 0755) == -1 &&
errno != EEXIST)
fatal("add_directory: %s: %s", cf->file_path,
@@ -159,12 +162,14 @@ add_directory(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);
cvs_ent_close(entlist, ENT_SYNC);
-
- cvs_printf("Directory %s added to the repository\n",
- cf->file_rpath);
}
}
+ if (added == 1) {
+ cvs_printf("Directory %s added to the repository\n",
+ cf->file_rpath);
+ }
+
cf->file_status = FILE_SKIP;
xfree(entry);
}
@@ -194,7 +199,7 @@ add_file(struct cvs_file *cf)
if (cf->file_rcs == NULL) {
cvs_log(LP_NOTICE, "cannot resurrect %s; "
"RCS file removed by second party", cf->file_name);
- } else {
+ } else if (cvs_noexec != 1) {
/*
* Remove the '-' prefixing the version number and
* restore the file.
@@ -223,14 +228,18 @@ add_file(struct cvs_file *cf)
if (b == NULL)
fatal("cvs_add_local: failed to get HEAD");
- cvs_checkout_file(cf, cf->file_rcs->rf_head, b, 0);
+ cvs_checkout_file(cf, head, b, 0);
cvs_printf("U %s\n", cf->file_path);
cvs_log(LP_NOTICE, "%s, version %s, resurrected",
cf->file_name, revbuf);
cf->file_status = FILE_UPTODATE;
+ } else {
+ cvs_log(LP_NOTICE, "%s, version %s, ressurected",
+ cf->file_name, revbuf);
}
+
stop = 1;
break;
case FILE_CONFLICT:
@@ -261,15 +270,17 @@ add_file(struct cvs_file *cf)
if (stop == 1)
return;
- entry = xmalloc(CVS_ENT_MAXLINELEN);
- l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/0/Initial %s//",
- cf->file_name, cf->file_name);
+ if (added != 0 && cvs_noexec != 1) {
+ entry = xmalloc(CVS_ENT_MAXLINELEN);
+ l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/0/Initial %s//",
+ cf->file_name, cf->file_name);
- entlist = cvs_ent_open(cf->file_wd);
- cvs_ent_add(entlist, entry);
- cvs_ent_close(entlist, ENT_SYNC);
+ entlist = cvs_ent_open(cf->file_wd);
+ cvs_ent_add(entlist, entry);
+ cvs_ent_close(entlist, ENT_SYNC);
- xfree(entry);
+ xfree(entry);
+ }
if (added != 0) {
if (verbosity > 0)
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 4a4bb408428..b4b33f4ca34 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.68 2006/06/01 20:00:52 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.69 2006/06/04 09:52:56 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -159,6 +159,9 @@ cvs_commit_local(struct cvs_file *cf)
cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path);
cvs_file_classify(cf, NULL, 0);
+ if (cvs_noexec == 1)
+ return;
+
if (cf->file_type != CVS_FILE)
fatal("cvs_commit_local: '%s' is not a file", cf->file_path);
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index e137c07c0bf..894eab1d3a4 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.47 2006/06/01 20:01:31 joris Exp $ */
+/* $OpenBSD: import.c,v 1.48 2006/06/04 09:52:56 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -89,8 +89,10 @@ cvs_import(int argc, char **argv)
if (l == -1 || l >= (int)sizeof(repo))
fatal("cvs_import: overflow");
- if (mkdir(repo, 0755) == -1 && errno != EEXIST)
- fatal("cvs_import: %s: %s", repo, strerror(errno));
+ if (cvs_noexec != 1) {
+ if (mkdir(repo, 0755) == -1 && errno != EEXIST)
+ fatal("cvs_import: %s: %s", repo, strerror(errno));
+ }
cr.enterdir = NULL;
cr.leavedir = NULL;
@@ -132,6 +134,8 @@ cvs_import_local(struct cvs_file *cf)
if (verbosity > 1)
cvs_log(LP_NOTICE, "Importing %s", cf->file_path);
+ if (cvs_noexec == 1)
+ return;
if (mkdir(cf->file_rpath, 0755) == -1 && errno != EEXIST)
fatal("cvs_import_local: %s: %s", cf->file_rpath,
@@ -167,6 +171,11 @@ import_new(struct cvs_file *cf)
cvs_log(LP_TRACE, "import_new(%s)", cf->file_name);
+ if (cvs_noexec == 1) {
+ cvs_printf("N %s/%s\n", import_repository, cf->file_path);
+ return;
+ }
+
if ((branch = rcsnum_parse(import_branch)) == NULL)
fatal("import_new: failed to parse branch");
@@ -272,6 +281,7 @@ import_update(struct cvs_file *cf)
if (rcs_deltatext_set(cf->file_rcs, newrev, d) == -1)
fatal("import_update: failed to set deltatext");
+
xfree(d);
import_tag(cf, brev, newrev);
@@ -296,11 +306,13 @@ import_tag(struct cvs_file *cf, RCSNUM *branch, RCSNUM *newrev)
{
char b[16];
- rcsnum_tostr(branch, b, sizeof(b));
- rcs_sym_add(cf->file_rcs, vendor_tag, branch);
+ if (cvs_noexec != 1) {
+ rcsnum_tostr(branch, b, sizeof(b));
+ rcs_sym_add(cf->file_rcs, vendor_tag, branch);
- rcsnum_tostr(newrev, b, sizeof(b));
- rcs_sym_add(cf->file_rcs, release_tag, newrev);
+ rcsnum_tostr(newrev, b, sizeof(b));
+ rcs_sym_add(cf->file_rcs, release_tag, newrev);
+ }
}
static char *
@@ -318,17 +330,19 @@ import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev)
b3 = cvs_buf_alloc(128, BUF_AUTOEXT);
- (void)xasprintf(&p1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir);
- cvs_buf_write_stmp(b1, p1, 0600, NULL);
- cvs_buf_free(b1);
+ if (cvs_noexec != 1) {
+ (void)xasprintf(&p1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir);
+ cvs_buf_write_stmp(b1, p1, 0600, NULL);
+ cvs_buf_free(b1);
- (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir);
- cvs_buf_write_stmp(b2, p2, 0600, NULL);
- cvs_buf_free(b2);
+ (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir);
+ cvs_buf_write_stmp(b2, p2, 0600, NULL);
+ cvs_buf_free(b2);
- diff_format = D_RCSDIFF;
- if (cvs_diffreg(p2, p1, b3) == D_ERROR)
- fatal("import_get_rcsdiff: failed to get RCS patch");
+ diff_format = D_RCSDIFF;
+ if (cvs_diffreg(p2, p1, b3) == D_ERROR)
+ fatal("import_get_rcsdiff: failed to get RCS patch");
+ }
cvs_buf_putc(b3, '\0');
delta = cvs_buf_release(b3);
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index b54157d744d..6ecc1608047 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.180 2006/06/01 20:00:52 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.181 2006/06/04 09:52:56 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -375,6 +375,9 @@ rcs_write(RCSFILE *rfp)
if (rfp->rf_flags & RCS_SYNCED)
return;
+ if (cvs_noexec == 1)
+ return;
+
/* Write operations need the whole file parsed */
rcs_parse_deltatexts(rfp, NULL);