summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-01-24 17:42:27 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-01-24 17:42:27 +0000
commitf94357d3e62ac2336f1e0185fba32d1ca190c24c (patch)
treeeab531e966d7956a50b57a051718cc3f28126eb9 /usr.bin
parent9f382d3d6d34d4bca87a9728f97fc581846d82bc (diff)
* use the global cvs_msg instead of our own
* support the use of RCS keyword expansion flags in client mode
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/add.c37
-rw-r--r--usr.bin/cvs/cvs.c6
2 files changed, 31 insertions, 12 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 19ed3e5219d..61833ca1c4e 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.12 2004/12/30 20:37:56 jfb Exp $ */
+/* $OpenBSD: add.c,v 1.13 2005/01/24 17:42:26 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -53,19 +53,31 @@ int cvs_add_file (CVSFILE *, void *);
int
cvs_add(int argc, char **argv)
{
- int i, ch;
- char *kflag, *msg;
+ int i, ch, kflag;
+ char buf[16], *koptstr;
struct cvsroot *root;
- kflag = msg = NULL;
+ kflag = RCS_KWEXP_DEFAULT;
+ cvs_msg = NULL;
while ((ch = getopt(argc, argv, "k:m:")) != -1) {
switch (ch) {
case 'k':
- kflag = optarg;
+ koptstr = optarg;
+ kflag = rcs_kflag_get(koptstr);
+ if (RCS_KWEXP_INVAL(kflag)) {
+ cvs_log(LP_ERR,
+ "invalid RCS keyword expansion mode");
+ rcs_kflag_usage();
+ return (EX_USAGE);
+ }
+ printf("kopt = `%s'\n", koptstr);
break;
case 'm':
- msg = optarg;
+ if ((cvs_msg = strdup(optarg)) == NULL) {
+ cvs_log(LP_ERRNO, "failed to copy message");
+ return (EX_DATAERR);
+ }
break;
default:
return (EX_USAGE);
@@ -74,7 +86,6 @@ cvs_add(int argc, char **argv)
argc -= optind;
argv += optind;
-
if (argc == 0)
return (EX_USAGE);
@@ -90,8 +101,16 @@ cvs_add(int argc, char **argv)
"or set the CVSROOT environment variable.");
return (EX_USAGE);
}
- if ((root->cr_method != CVS_METHOD_LOCAL) && (cvs_connect(root) < 0))
- return (EX_PROTOCOL);
+ if (root->cr_method != CVS_METHOD_LOCAL) {
+ if (cvs_connect(root) < 0)
+ return (EX_PROTOCOL);
+ if (kflag != RCS_KWEXP_DEFAULT) {
+ strlcpy(buf, "-k", sizeof(buf));
+ strlcat(buf, koptstr, sizeof(buf));
+ if (cvs_sendarg(root, buf, 0) < 0)
+ return (EX_PROTOCOL);
+ }
+ }
cvs_file_examine(cvs_files, cvs_add_file, NULL);
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 607c24eb0c6..1f0265d22fb 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.36 2005/01/24 16:12:56 jfb Exp $ */
+/* $OpenBSD: cvs.c,v 1.37 2005/01/24 17:42:26 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -96,8 +96,8 @@ static struct cvs_cmd {
} cvs_cdt[] = {
{
CVS_OP_ADD, "add", { "ad", "new" }, cvs_add,
- "[-m msg] file ...",
- "",
+ "[-k opt] [-m msg] file ...",
+ "k:m:",
"Add a new file/directory to the repository",
NULL,
},