summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-22 22:12:01 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-22 22:12:01 +0000
commitdcb179a96c41a7ce8d90128b6e6b86ffae1bcff9 (patch)
tree808602d178c334ad0fbdb44098e690be743cd767
parent4abe01f2de3129da565d327402d7d88766ffb9bb (diff)
- support -c and -s to retrieve the module list
- silently accept most of the other options supported by checkout - do not abandon all hope if the `expand-modules' request fails
-rw-r--r--usr.bin/cvs/checkout.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 63280bf8592..eeca51f859c 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.12 2004/12/14 01:11:51 jfb Exp $ */
+/* $OpenBSD: checkout.c,v 1.13 2005/02/22 22:12:00 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -39,6 +39,9 @@
#include "proto.h"
+#define CVS_LISTMOD 1
+#define CVS_STATMOD 2
+
/*
* cvs_checkout()
@@ -49,12 +52,50 @@
int
cvs_checkout(int argc, char **argv)
{
- int i, ch;
+ int i, ch, statmod, kflag;
+ char *date, *rev, *koptstr, *tgtdir, *rcsid;
struct cvsroot *root;
- while ((ch = getopt(argc, argv, "c")) != -1) {
+ statmod = 0;
+ rcsid = NULL;
+ tgtdir = NULL;
+ kflag = RCS_KWEXP_DEFAULT;
+
+ while ((ch = getopt(argc, argv, "AcD:d:fj:k:lNnPRr:st:")) != -1) {
switch (ch) {
+ case 'A':
+ break;
case 'c':
+ statmod = CVS_LISTMOD;
+ break;
+ case 'D':
+ date = optarg;
+ break;
+ case 'd':
+ tgtdir = optarg;
+ break;
+ case 'f':
+ break;
+ case 'j':
+ break;
+ case 'k':
+ 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);
+ }
+ break;
+ case 'r':
+ rev = optarg;
+ break;
+ case 's':
+ statmod = CVS_STATMOD;
+ break;
+ case 't':
+ rcsid = optarg;
break;
default:
return (EX_USAGE);
@@ -64,12 +105,17 @@ cvs_checkout(int argc, char **argv)
argc -= optind;
argv += optind;
- if (argc == 0) {
+ if (!statmod && (argc == 0)) {
cvs_log(LP_ERR,
"must specify at least one module or directory");
return (EX_USAGE);
}
+ if (statmod && (argc > 0)) {
+ cvs_log(LP_ERR, "-c and -s must not get any arguments");
+ return (EX_USAGE);
+ }
+
if ((cvs_files = cvs_file_get(".", 0)) == NULL)
return (EX_USAGE);
@@ -90,14 +136,23 @@ cvs_checkout(int argc, char **argv)
if (cvs_sendarg(root, argv[i], 0) < 0)
break;
- if ((cvs_senddir(root, cvs_files) < 0) ||
- (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0))
+ if (cvs_senddir(root, cvs_files) < 0)
+ return (EX_PROTOCOL);
+ if (cvs_sendreq(root, CVS_REQ_XPANDMOD, NULL) < 0)
cvs_log(LP_ERR, "failed to expand module");
/* XXX not too sure why we have to send this arg */
if (cvs_sendarg(root, "-N", 0) < 0)
return (EX_PROTOCOL);
+ if ((statmod == CVS_LISTMOD) &&
+ (cvs_sendarg(root, "-c", 0) < 0))
+ return (EX_PROTOCOL);
+
+ if ((statmod == CVS_STATMOD) &&
+ (cvs_sendarg(root, "-s", 0) < 0))
+ return (EX_PROTOCOL);
+
for (i = 0; i < argc; i++)
if (cvs_sendarg(root, argv[i], 0) < 0)
return (EX_PROTOCOL);