diff options
author | 2007-01-26 21:48:16 +0000 | |
---|---|---|
committer | 2007-01-26 21:48:16 +0000 | |
commit | 56f996a25db7a342802e62d08ce5f37fa6d19ea3 (patch) | |
tree | 0270a4d8713844457ae8b8c52e49f4c07aacda7d | |
parent | Document which AS are designated for private use and which are reserved (diff) | |
download | wireguard-openbsd-56f996a25db7a342802e62d08ce5f37fa6d19ea3.tar.xz wireguard-openbsd-56f996a25db7a342802e62d08ce5f37fa6d19ea3.zip |
- support [-k mode] for the add command
- do not let the file keyword expension options (-k) disappear
from the Entries file when doing a commit/update/checkout
- be sure the expension mode gets written to the RCS file when a file
is added/committed in the first place
problems raised by otto@; tests/ok otto@ and joris@.
-rw-r--r-- | usr.bin/cvs/add.c | 30 | ||||
-rw-r--r-- | usr.bin/cvs/checkout.c | 21 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 9 | ||||
-rw-r--r-- | usr.bin/cvs/commit.c | 9 | ||||
-rw-r--r-- | usr.bin/cvs/rcs.c | 3 |
5 files changed, 55 insertions, 17 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 5687d1b0a26..af5ed955fc1 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.71 2007/01/26 06:21:51 otto Exp $ */ +/* $OpenBSD: add.c,v 1.72 2007/01/26 21:48:16 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -32,14 +32,17 @@ 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; + char *logmsg; struct cvs_cmd cvs_cmd_add = { CVS_OP_ADD, 0, "add", { "ad", "new" }, "Add a new file or directory to the repository", - "[-m message] ...", - "m:", + "[-k mode] [-m message] ...", + "k:m:", NULL, cvs_add }; @@ -55,6 +58,16 @@ 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); + if (RCS_KWEXP_INVAL(kflag)) { + cvs_log(LP_ERR, + "invalid RCS keyword expension mode"); + fatal("%s", cvs_cmd_add.cmd_synopsis); + } + snprintf(kbuf, sizeof(kbuf), "-k%s", koptstr); + break; case 'm': logmsg = xstrdup(optarg); break; @@ -76,6 +89,9 @@ cvs_add(int argc, char **argv) cvs_client_connect_to_server(); cr.fileproc = cvs_client_sendfile; + if (kflag != RCS_KWEXP_DEFAULT) + cvs_client_send_request("Argument %s", kbuf); + if (logmsg != NULL) cvs_client_send_request("Argument -m%s", logmsg); } else { @@ -334,7 +350,8 @@ add_entry(struct cvs_file *cf) /* Remove the '-' prefixing the version number. */ l = snprintf(entry, CVS_ENT_MAXLINELEN, - "/%s/%s/%s//", cf->file_name, revbuf, tbuf); + "/%s/%s/%s/%s/", cf->file_name, revbuf, tbuf, + cf->file_ent->ce_opts ? cf->file_ent->ce_opts : ""); if (l == -1 || l >= CVS_ENT_MAXLINELEN) fatal("add_entry: truncation"); } else { @@ -356,8 +373,9 @@ add_entry(struct cvs_file *cf) (void)fclose(fp); } - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/0/Initial %s//", - cf->file_name, cf->file_name); + l = snprintf(entry, CVS_ENT_MAXLINELEN, + "/%s/0/Initial %s/%s/", cf->file_name, cf->file_name, + (kflag != RCS_KWEXP_DEFAULT) ? kbuf : ""); if (l == -1 || l >= CVS_ENT_MAXLINELEN) fatal("add_entry: truncation"); } diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index d6f7257e902..ea04b7f3530 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.84 2007/01/26 11:19:44 joris Exp $ */ +/* $OpenBSD: checkout.c,v 1.85 2007/01/26 21:48:17 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -199,12 +199,12 @@ checkout_repository(const char *repobase, const char *wdbase) void cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) { - int l, oflags, exists; + int kflag, l, oflags, exists; time_t rcstime; CVSENTRIES *ent; struct timeval tv[2]; char *template, *p, *entry, rev[16], timebuf[64]; - char tbuf[32], stickytag[32]; + char kbuf[8], tbuf[32], stickytag[32]; rcsnum_tostr(rnum, rev, sizeof(rev)); @@ -278,9 +278,20 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) stickytag[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)) + snprintf(kbuf, sizeof(kbuf), + "-k%s", cf->file_rcs->rf_expand); + } + entry = xmalloc(CVS_ENT_MAXLINELEN); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//%s", cf->file_name, - rev, timebuf, stickytag); + l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s", + cf->file_name, rev, timebuf, kbuf, stickytag); if (cvs_server_active == 0) { ent = cvs_ent_open(cf->file_wd); diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index 01ae9a8a434..de0970475a3 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.52 2007/01/26 11:19:44 joris Exp $ */ +/* $OpenBSD: client.c,v 1.53 2007/01/26 21:48:17 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -472,7 +472,8 @@ cvs_client_sendfile(struct cvs_file *cf) cvs_client_send_request("Entry /%s/%s%s/%s//%s", cf->file_name, (cf->file_status == FILE_REMOVED) ? "-" : "", - rev, timebuf, sticky); + rev, timebuf, cf->file_ent->ce_opts ? + cf->file_ent->ce_opts : "", sticky); } switch (cf->file_status) { @@ -588,9 +589,9 @@ cvs_client_checkedin(char *data) fatal("cvs_client_checkedin: overflow"); } - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s%s/%s//%s/", + l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s%s/%s/%s/%s", newent->ce_name, (newent->ce_status == CVS_ENT_REMOVED) ? "-" : "", - rev, timebuf, sticky); + rev, timebuf, ent->ce_opts ? ent->ce_opts : "", sticky); if (l == -1 || l >= CVS_ENT_MAXLINELEN) fatal("cvs_client_checkedin: overflow"); diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index eb7b6e2f635..0b929a28371 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.100 2007/01/25 18:56:33 otto Exp $ */ +/* $OpenBSD: commit.c,v 1.101 2007/01/26 21:48:17 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -321,6 +321,13 @@ cvs_commit_local(struct cvs_file *cf) cf->file_rcs->rf_branch = NULL; } + if (cf->file_status == FILE_ADDED && cf->file_ent->ce_opts != NULL) { + int kflag; + + kflag = rcs_kflag_get(cf->file_ent->ce_opts + 2); + rcs_kwexp_set(cf->file_rcs, kflag); + } + rcs_write(cf->file_rcs); if (cf->file_status == FILE_REMOVED) { diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index 2de6a08c313..28f633bd73b 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.204 2007/01/26 11:19:44 joris Exp $ */ +/* $OpenBSD: rcs.c,v 1.205 2007/01/26 21:48:17 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -1466,6 +1466,7 @@ rcs_kflag_get(const char *flags) } else if (*fp == 'b') { if (len != 1) fl |= RCS_KWEXP_ERR; + fl |= RCS_KWEXP_NONE; } else /* unknown letter */ fl |= RCS_KWEXP_ERR; } |