diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-26 21:48:18 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-26 21:48:18 +0000 |
commit | 1dc1e685e35f59cc0cd89a24510839b45f0150da (patch) | |
tree | 8c789f604084d7b0d74c6528814f7f7877d7baa4 /usr.bin/cvs/add.c | |
parent | 5fe1d95edff25df017aaf72fcf4bfc72a3936053 (diff) |
- 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@.
Diffstat (limited to 'usr.bin/cvs/add.c')
-rw-r--r-- | usr.bin/cvs/add.c | 30 |
1 files changed, 24 insertions, 6 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"); } |