diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-29 10:55:38 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-11-29 10:55:38 +0000 |
commit | 9ff7dd7e4569c04817d6ca029a89ca2877d939f1 (patch) | |
tree | e6de93433811eadcb6fed266754fd2f3fbed02e4 /usr.bin | |
parent | 31a6537e2767ec76d3f310a554707474aa349d60 (diff) |
some more bits for `-w[user]' support;
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/co.1 | 6 | ||||
-rw-r--r-- | usr.bin/rcs/co.c | 27 |
2 files changed, 19 insertions, 14 deletions
diff --git a/usr.bin/rcs/co.1 b/usr.bin/rcs/co.1 index e6272e0ad9e..431136db271 100644 --- a/usr.bin/rcs/co.1 +++ b/usr.bin/rcs/co.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: co.1,v 1.16 2005/11/27 10:55:38 jmc Exp $ +.\" $OpenBSD: co.1,v 1.17 2005/11/29 10:55:37 xsa Exp $ .\" .\" Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org> .\" All rights reserved. @@ -36,7 +36,7 @@ .Op Fl r Ns Op Ar rev .Op Fl s Ns Ar state .Op Fl u Ns Op Ar rev -.Op Fl w Ns Ar user +.Op Fl w Ns Op Ar user .Op Fl x Ns Ar suffixes .Op Fl z Ns Ar tz .Ar file ... @@ -95,7 +95,7 @@ but also unlocks the retrieved revision if it was locked. Preserve the modification time of RCS files. .It Fl V Print RCS's version number. -.It Fl w Ns Ar user +.It Fl w Ns Op Ar user Retrieve the latest revision which was checked in by the specified .Ar user . If the diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c index f5d1286243f..83afdf41e22 100644 --- a/usr.bin/rcs/co.c +++ b/usr.bin/rcs/co.c @@ -1,4 +1,4 @@ -/* $OpenBSD: co.c,v 1.37 2005/11/25 13:50:01 xsa Exp $ */ +/* $OpenBSD: co.c,v 1.38 2005/11/29 10:55:37 xsa Exp $ */ /* * Copyright (c) 2005 Joris Vink <joris@openbsd.org> * All rights reserved. @@ -36,6 +36,8 @@ #include "rcs.h" #include "rcsprog.h" +#define CO_OPTSTRING "f::k:l::M::p::q::r::s:Tu::Vw::x:" + static int checkout_state(RCSFILE *, RCSNUM *, const char *, int, const char *, const char *); @@ -47,20 +49,16 @@ checkout_main(int argc, char **argv) RCSFILE *file; char fpath[MAXPATHLEN], buf[16]; char *username; - const char *state = NULL; + const char *state; time_t rcs_mtime = -1; flags = 0; kflag = RCS_KWEXP_ERR; rev = RCS_HEAD_REV; frev = NULL; + state = username = NULL; - if ((username = getlogin()) == NULL) { - cvs_log(LP_ERRNO, "failed to get username"); - exit (1); - } - - while ((ch = rcs_getopt(argc, argv, "f::k:l::M::p::q::r::s:Tu::Vx:")) != -1) { + while ((ch = rcs_getopt(argc, argv, CO_OPTSTRING)) != -1) { switch (ch) { case 'f': rcs_set_rev(rcs_optarg, &rev); @@ -111,6 +109,9 @@ checkout_main(int argc, char **argv) case 'V': printf("%s\n", rcs_version); exit(0); + case 'w': + username = rcs_optarg; + break; case 'x': rcs_suffixes = rcs_optarg; break; @@ -129,6 +130,11 @@ checkout_main(int argc, char **argv) exit (1); } + if ((username == NULL) && ((username = getlogin()) == NULL)) { + cvs_log(LP_ERRNO, "failed to get username"); + exit (1); + } + for (i = 0; i < argc; i++) { if (rcs_statfile(argv[i], fpath, sizeof(fpath)) < 0) continue; @@ -190,7 +196,7 @@ checkout_usage(void) fprintf(stderr, "usage: co [-V] [-ddate] [-f[rev]] [-I[rev]] [-kmode] [-l[rev]]\n" " [-M[rev]] [-mmsg] [-p[rev]] [-q[rev]] [-r[rev]]\n" - " [-sstate] [-u[rev]] [-wuser] [-xsuffixes] [-ztz] file ...\n"); + " [-sstate] [-u[rev]] [-w[user]] [-xsuffixes] [-ztz] file ...\n"); } /* @@ -319,8 +325,7 @@ checkout_state(RCSFILE *rfp, RCSNUM *rev, const char *dst, int flags, cvs_log(LP_ERR, "%s: No revision on branch has state %s", rfp->rf_path, state); return (-1); - } - else { + } else { if (((tstate = rcs_state_get(rfp, rev)) != NULL) && (strcmp(state, tstate) == 0)) return (checkout_rev(rfp, rev, dst, flags, username)); |