summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-02-04 15:07:34 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-02-04 15:07:34 +0000
commit411b75fbdfa56ff0a00aa9ce3c23e4674c30bcfd (patch)
treeb28e12816c4e0d77510c52ab19889c16ba4e0ecd /usr.bin/cvs
parent78441b321b1022d3be5daeabc9c2234895287cee (diff)
Added -k flag support for all commands which support it.
OK joris@
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/add.c15
-rw-r--r--usr.bin/cvs/admin.c5
-rw-r--r--usr.bin/cvs/checkout.c38
-rw-r--r--usr.bin/cvs/commit.c8
-rw-r--r--usr.bin/cvs/cvs.h3
-rw-r--r--usr.bin/cvs/diff.c33
-rw-r--r--usr.bin/cvs/edit.c7
-rw-r--r--usr.bin/cvs/import.c9
-rw-r--r--usr.bin/cvs/remove.c9
-rw-r--r--usr.bin/cvs/update.c39
10 files changed, 118 insertions, 48 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 81fefeee44b..df2f7a78204 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.89 2008/01/31 10:17:47 tobias Exp $ */
+/* $OpenBSD: add.c,v 1.90 2008/02/04 15:07:32 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -35,8 +35,8 @@ static void add_directory(struct cvs_file *);
static void add_file(struct cvs_file *);
static void add_entry(struct cvs_file *);
-static int kflag = RCS_KWEXP_DEFAULT;
-static char kbuf[8], *koptstr;
+int kflag = 0;
+static char kbuf[8];
char *logmsg;
@@ -62,14 +62,13 @@ cvs_add(int argc, char **argv)
while ((ch = getopt(argc, argv, cvs_cmd_add.cmd_opts)) != -1) {
switch (ch) {
case 'k':
- koptstr = optarg;
- kflag = rcs_kflag_get(koptstr);
+ kflag = rcs_kflag_get(optarg);
if (RCS_KWEXP_INVAL(kflag)) {
cvs_log(LP_ERR,
"invalid RCS keyword expension mode");
fatal("%s", cvs_cmd_add.cmd_synopsis);
}
- (void)xsnprintf(kbuf, sizeof(kbuf), "-k%s", koptstr);
+ (void)xsnprintf(kbuf, sizeof(kbuf), "-k%s", optarg);
break;
case 'm':
logmsg = optarg;
@@ -92,7 +91,7 @@ cvs_add(int argc, char **argv)
cvs_client_connect_to_server();
cr.fileproc = cvs_add_remote;
- if (kflag != RCS_KWEXP_DEFAULT)
+ if (kflag);
cvs_client_send_request("Argument %s", kbuf);
if (logmsg != NULL)
@@ -406,7 +405,7 @@ add_entry(struct cvs_file *cf)
(void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
"/%s/0/Initial %s/%s/", cf->file_name, cf->file_name,
- (kflag != RCS_KWEXP_DEFAULT) ? kbuf : "");
+ kflag ? kbuf : "");
}
if (cvs_server_active) {
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 6a00daadec3..3e8775fdba6 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.54 2008/01/31 21:52:48 tobias Exp $ */
+/* $OpenBSD: admin.c,v 1.55 2008/02/04 15:07:32 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -49,7 +49,6 @@ struct cvs_cmd cvs_cmd_admin = {
static int runflags = 0;
static int lkmode = RCS_LOCK_INVAL;
-static int kflag = RCS_KWEXP_DEFAULT;
static char *alist, *comment, *elist, *logmsg, *logstr, *koptstr;
static char *oldfilename, *orange, *state, *statestr;
static RCSNUM *logrev;
@@ -299,7 +298,7 @@ cvs_admin_local(struct cvs_file *cf)
}
/* Default `-kv' is accepted here. */
- if (koptstr != NULL) {
+ if (kflag) {
if (cf->file_rcs->rf_expand == NULL ||
strcmp(cf->file_rcs->rf_expand, koptstr) != 0)
rcs_kwexp_set(cf->file_rcs, kflag);
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 2977edd3d58..31f818ab07c 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.124 2008/02/03 23:34:41 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.125 2008/02/04 15:07:32 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -40,6 +40,7 @@ extern int build_dirs;
static int flags = CR_REPO | CR_RECURSE_DIRS;
static char *dflag = NULL;
+static char *koptstr = NULL;
struct cvs_cmd cvs_cmd_checkout = {
CVS_OP_CHECKOUT, CVS_USE_WDIR, "checkout",
@@ -77,6 +78,15 @@ cvs_checkout(int argc, char **argv)
fatal("-d specified two or more times");
dflag = optarg;
break;
+ case 'k':
+ koptstr = optarg;
+ kflag = rcs_kflag_get(koptstr);
+ if (RCS_KWEXP_INVAL(kflag)) {
+ cvs_log(LP_ERR,
+ "invalid RCS keyword expension mode");
+ fatal("%s", cvs_cmd_add.cmd_synopsis);
+ }
+ break;
case 'l':
flags &= ~CR_RECURSE_DIRS;
break;
@@ -121,6 +131,15 @@ cvs_export(int argc, char **argv)
while ((ch = getopt(argc, argv, cvs_cmd_export.cmd_opts)) != -1) {
switch (ch) {
+ case 'k':
+ koptstr = optarg;
+ kflag = rcs_kflag_get(koptstr);
+ if (RCS_KWEXP_INVAL(kflag)) {
+ cvs_log(LP_ERR,
+ "invalid RCS keyword expension mode");
+ fatal("%s", cvs_cmd_add.cmd_synopsis);
+ }
+ break;
case 'l':
flags &= ~CR_RECURSE_DIRS;
break;
@@ -171,6 +190,9 @@ checkout_check_repository(int argc, char **argv)
if (reset_stickies == 1)
cvs_client_send_request("Argument -A");
+ if (kflag)
+ cvs_client_send_request("Argument -k%s", koptstr);
+
if (dflag != NULL)
cvs_client_send_request("Argument -d%s", dflag);
@@ -361,7 +383,7 @@ checkout_repository(const char *repobase, const char *wdbase)
void
cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
{
- int kflag, oflags, exists;
+ int cf_kflag, oflags, exists;
time_t rcstime;
CVSENTRIES *ent;
struct timeval tv[2];
@@ -447,14 +469,14 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, char *tag, int co_flags)
sticky[0] = '\0';
kbuf[0] = '\0';
- if (cf->file_ent != NULL) {
- if (cf->file_ent->ce_opts != NULL)
- strlcpy(kbuf, cf->file_ent->ce_opts, sizeof(kbuf));
- } else if (cf->file_rcs->rf_expand != NULL) {
- kflag = rcs_kflag_get(cf->file_rcs->rf_expand);
- if (!(kflag & RCS_KWEXP_DEFAULT))
+ if (cf->file_rcs->rf_expand != NULL) {
+ cf_kflag = rcs_kflag_get(cf->file_rcs->rf_expand);
+ if (kflag || cf_kflag != RCS_KWEXP_DEFAULT)
(void)xsnprintf(kbuf, sizeof(kbuf),
"-k%s", cf->file_rcs->rf_expand);
+ } else if (!reset_stickies && cf->file_ent != NULL) {
+ if (cf->file_ent->ce_opts != NULL)
+ strlcpy(kbuf, cf->file_ent->ce_opts, sizeof(kbuf));
}
(void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s",
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 5156eb32700..bbc302e1797 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.125 2008/01/31 22:11:38 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.126 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -456,10 +456,10 @@ cvs_commit_local(struct cvs_file *cf)
}
if (cf->file_status == FILE_ADDED && cf->file_ent->ce_opts != NULL) {
- int kflag;
+ int cf_kflag;
- kflag = rcs_kflag_get(cf->file_ent->ce_opts + 2);
- rcs_kwexp_set(cf->file_rcs, kflag);
+ cf_kflag = rcs_kflag_get(cf->file_ent->ce_opts + 2);
+ rcs_kwexp_set(cf->file_rcs, cf_kflag);
}
rcs_write(cf->file_rcs);
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index d8be3b4a7ff..1b078ffdaee 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.152 2008/02/03 22:50:28 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.153 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -319,6 +319,7 @@ extern int cvs_readonlyfs;
extern int cvs_error;
extern int cvs_server_active;
extern int reset_stickies;
+extern int kflag;
extern struct cvs_cmd *cmdp;
extern struct cvs_cmd *cvs_cdt[];
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index e51d27ad80d..97bb3066192 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.125 2008/02/03 18:18:44 tobias Exp $ */
+/* $OpenBSD: diff.c,v 1.126 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -29,10 +29,11 @@
void cvs_diff_local(struct cvs_file *);
-static int Nflag = 0;
-static int force_head = 0;
-static char *rev1 = NULL;
-static char *rev2 = NULL;
+static int Nflag = 0;
+static int force_head = 0;
+static char *koptstr;
+static char *rev1 = NULL;
+static char *rev2 = NULL;
struct cvs_cmd cvs_cmd_diff = {
CVS_OP_DIFF, CVS_USE_WDIR, "diff",
@@ -40,7 +41,7 @@ struct cvs_cmd cvs_cmd_diff = {
"Show differences between revisions",
"[-cilNnpRu] [[-D date] [-r rev] [-D date2 | -r rev2]] "
"[-k mode] [file ...]",
- "cfD:iklNnpr:Ru",
+ "cfD:ik:lNnpr:Ru",
NULL,
cvs_diff
};
@@ -51,7 +52,7 @@ struct cvs_cmd cvs_cmd_rdiff = {
"Show differences between revisions",
"[-flR] [-c | -u] [-s | -t] [-V ver] -D date | -r rev\n"
"[-D date2 | -r rev2] [-k mode] module ...",
- "cfD:klr:Ru",
+ "cfD:k:lr:RuV:",
NULL,
cvs_diff
};
@@ -80,6 +81,15 @@ cvs_diff(int argc, char **argv)
strlcat(diffargs, " -i", sizeof(diffargs));
diff_iflag = 1;
break;
+ case 'k':
+ koptstr = optarg;
+ kflag = rcs_kflag_get(koptstr);
+ if (RCS_KWEXP_INVAL(kflag)) {
+ cvs_log(LP_ERR,
+ "invalid RCS keyword expension mode");
+ fatal("%s", cvs_cmd_add.cmd_synopsis);
+ }
+ break;
case 'l':
flags &= ~CR_RECURSE_DIRS;
break;
@@ -111,6 +121,9 @@ cvs_diff(int argc, char **argv)
strlcat(diffargs, " -u", sizeof(diffargs));
diff_format = D_UNIFIED;
break;
+ case 'V':
+ fatal("the -V option is obsolete "
+ "and should not be used");
default:
fatal("%s", cvs_cmd_diff.cmd_synopsis);
}
@@ -141,6 +154,9 @@ cvs_diff(int argc, char **argv)
if (!(flags & CR_RECURSE_DIRS))
cvs_client_send_request("Argument -l");
+ if (kflag)
+ cvs_client_send_request("Argument -k%s", koptstr);
+
switch (diff_format) {
case D_CONTEXT:
cvs_client_send_request("Argument -c");
@@ -239,6 +255,9 @@ cvs_diff_local(struct cvs_file *cf)
return;
}
+ if (kflag)
+ rcs_kwexp_set(cf->file_rcs, kflag);
+
if (rev1 != NULL)
if ((diff_rev1 = rcs_translate_tag(rev1, cf->file_rcs)) ==
NULL) {
diff --git a/usr.bin/cvs/edit.c b/usr.bin/cvs/edit.c
index 209f9170041..c885436f9bb 100644
--- a/usr.bin/cvs/edit.c
+++ b/usr.bin/cvs/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.42 2008/01/31 10:15:05 tobias Exp $ */
+/* $OpenBSD: edit.c,v 1.43 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2006, 2007 Xavier Santolaria <xsa@openbsd.org>
*
@@ -400,9 +400,8 @@ cvs_unedit_local(struct cvs_file *cf)
timebuf[strcspn(timebuf, "\n")] = '\0';
(void)xasprintf(&entry, "/%s/%s/%s/%s/%s",
- cf->file_name, rbuf, timebuf,
- (cf->file_ent->ce_tag) ? cf->file_ent->ce_tag : "",
- (cf->file_ent->ce_opts) ? cf->file_ent->ce_opts : "");
+ cf->file_name, rbuf, timebuf, cf->file_ent->ce_opts ? : "",
+ cf->file_ent->ce_tag ? : "");
cvs_ent_add(entlist, entry);
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index 13cda70be9a..fe17c4dd71f 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.81 2008/01/31 21:30:08 joris Exp $ */
+/* $OpenBSD: import.c,v 1.82 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -40,7 +40,6 @@ static char *logmsg = NULL;
static char *vendor_tag = NULL;
static char *release_tag = NULL;
static char *koptstr;
-static int kflag = RCS_KWEXP_DEFAULT;
static int dflag = 0;
char *import_repository = NULL;
@@ -111,7 +110,7 @@ cvs_import(int argc, char **argv)
cvs_client_send_request("Argument -b%s", IMPORT_DEFAULT_BRANCH);
- if (kflag != RCS_KWEXP_DEFAULT)
+ if (kflag)
cvs_client_send_request("Argument -k%s", koptstr);
cvs_client_send_logmsg(logmsg);
@@ -273,7 +272,7 @@ import_new(struct cvs_file *cf)
cf->file_rcs->rf_head, bp) == -1)
fatal("import_new: failed to set deltatext");
- if (kflag != RCS_KWEXP_DEFAULT)
+ if (kflag)
rcs_kwexp_set(cf->file_rcs, kflag);
rcs_write(cf->file_rcs);
@@ -337,7 +336,7 @@ import_update(struct cvs_file *cf)
cvs_printf("U %s/%s\n", import_repository, cf->file_path);
}
- if (kflag != RCS_KWEXP_DEFAULT)
+ if (kflag)
rcs_kwexp_set(cf->file_rcs, kflag);
rcsnum_free(brev);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 026e783c3b0..64f0831ad46 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.69 2008/01/31 10:15:05 tobias Exp $ */
+/* $OpenBSD: remove.c,v 1.70 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
*
@@ -186,15 +186,16 @@ cvs_remove_local(struct cvs_file *cf)
}
return;
default:
- rcsnum_tostr(cf->file_ent->ce_rev, rbuf,
- sizeof(rbuf));
+ rcsnum_tostr(cf->file_ent->ce_rev, rbuf, sizeof(rbuf));
ctime_r(&cf->file_ent->ce_mtime, tbuf);
tbuf[strcspn(tbuf, "\n")] = '\0';
entry = xmalloc(CVS_ENT_MAXLINELEN);
(void)xsnprintf(entry, CVS_ENT_MAXLINELEN,
- "/%s/-%s/%s//", cf->file_name, rbuf, tbuf);
+ "/%s/-%s/%s/%s/%s", cf->file_name, rbuf, tbuf,
+ cf->file_ent->ce_opts ? : "",
+ cf->file_ent->ce_tag ? : "");
if (cvs_server_active == 1) {
cvs_server_update_entry("Checked-in", cf);
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 4044c87a3d2..465ca56a5df 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.118 2008/02/03 15:20:10 tobias Exp $ */
+/* $OpenBSD: update.c,v 1.119 2008/02/04 15:07:33 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -32,6 +32,8 @@ int build_dirs = 0;
int reset_stickies = 0;
char *cvs_specified_tag = NULL;
+static char *koptstr;
+
static void update_clear_conflict(struct cvs_file *);
struct cvs_cmd cvs_cmd_update = {
@@ -74,6 +76,13 @@ cvs_update(int argc, char **argv)
case 'j':
break;
case 'k':
+ koptstr = optarg;
+ kflag = rcs_kflag_get(koptstr);
+ if (RCS_KWEXP_INVAL(kflag)) {
+ cvs_log(LP_ERR,
+ "invalid RCS keyword expension mode");
+ fatal("%s", cvs_cmd_add.cmd_synopsis);
+ }
break;
case 'l':
flags &= ~CR_RECURSE_DIRS;
@@ -115,6 +124,8 @@ cvs_update(int argc, char **argv)
cvs_client_send_request("Argument -A");
if (build_dirs)
cvs_client_send_request("Argument -d");
+ if (kflag)
+ cvs_client_send_request("Argument -k%s", koptstr);
if (!(flags & CR_RECURSE_DIRS))
cvs_client_send_request("Argument -l");
if (prune_dirs)
@@ -280,7 +291,7 @@ cvs_update_local(struct cvs_file *cf)
char *tag;
int ret, flags;
CVSENTRIES *entlist;
- char rbuf[CVS_REV_BUFSZ];
+ char kbuf[8], rbuf[CVS_REV_BUFSZ];
cvs_log(LP_TRACE, "cvs_update_local(%s)", cf->file_path);
@@ -305,6 +316,9 @@ cvs_update_local(struct cvs_file *cf)
cvs_file_classify(cf, tag);
+ if (kflag)
+ rcs_kwexp_set(cf->file_rcs, kflag);
+
if (cf->file_ent != NULL && cf->file_ent->ce_tag != NULL)
tag = cf->file_ent->ce_tag;
@@ -337,6 +351,22 @@ cvs_update_local(struct cvs_file *cf)
return;
}
+ if (cf->file_ent != NULL) {
+ if (cf->file_ent->ce_opts == NULL) {
+ if (kflag)
+ cf->file_status = FILE_CHECKOUT;
+ } else {
+ if (kflag) {
+ (void)xsnprintf(kbuf, sizeof(kbuf),
+ "-k%s", cf->file_rcs->rf_expand);
+
+ if (strcmp(kbuf, cf->file_ent->ce_opts))
+ cf->file_status = FILE_CHECKOUT;
+ } else if (reset_stickies)
+ cf->file_status = FILE_CHECKOUT;
+ }
+ }
+
switch (cf->file_status) {
case FILE_UNKNOWN:
cvs_printf("? %s\n", cf->file_path);
@@ -425,8 +455,9 @@ update_clear_conflict(struct cvs_file *cf)
rcsnum_tostr(cf->file_ent->ce_rev, revbuf, sizeof(revbuf));
entry = xmalloc(CVS_ENT_MAXLINELEN);
- (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//",
- cf->file_name, revbuf, timebuf);
+ (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s",
+ cf->file_name, revbuf, timebuf, cf->file_ent->ce_opts ? : "",
+ cf->file_ent->ce_tag ? : "");
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_add(entlist, entry);