version 1.20, 2005/05/20 20:00:53 |
version 1.21, 2005/05/24 04:12:25 |
|
|
extern char *__progname; |
extern char *__progname; |
|
|
|
|
int cvs_add_file(CVSFILE *, void *); |
static int cvs_add_file(CVSFILE *, void *); |
int cvs_add_options(char *, int, char **, int *); |
static int cvs_add_init(struct cvs_cmd *, int, char **, int *); |
int cvs_add_sendflags(struct cvsroot *); |
static int cvs_add_pre_exec(struct cvsroot *); |
|
|
struct cvs_cmd_info cvs_add = { |
struct cvs_cmd cvs_cmd_add = { |
cvs_add_options, |
CVS_OP_ADD, CVS_REQ_ADD, "add", |
cvs_add_sendflags, |
{ "ad", "new" }, |
cvs_add_file, |
"Add a new file/directory to the repository", |
NULL, NULL, |
"[-k mode] [-m msg] file ...", |
|
"k:m:", |
|
NULL, |
0, |
0, |
CVS_REQ_ADD, |
cvs_add_init, |
|
cvs_add_pre_exec, |
|
cvs_add_file, |
|
cvs_add_file, |
|
NULL, |
|
NULL, |
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 |
CVS_CMD_ALLOWSPEC | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 |
}; |
}; |
|
|
static int kflag = RCS_KWEXP_DEFAULT; |
static int kflag = RCS_KWEXP_DEFAULT; |
static char *koptstr; |
static char *koptstr; |
|
|
int |
static int |
cvs_add_options(char *opt, int argc, char **argv, int *arg) |
cvs_add_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg) |
{ |
{ |
int ch; |
int ch; |
|
|
cvs_msg = NULL; |
cvs_msg = NULL; |
|
|
while ((ch = getopt(argc, argv, opt)) != -1) { |
while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) { |
switch (ch) { |
switch (ch) { |
case 'k': |
case 'k': |
koptstr = optarg; |
koptstr = optarg; |
|
|
return (0); |
return (0); |
} |
} |
|
|
int |
static int |
cvs_add_sendflags(struct cvsroot *root) |
cvs_add_pre_exec(struct cvsroot *root) |
{ |
{ |
char buf[16]; |
char buf[16]; |
|
|
if (kflag != RCS_KWEXP_DEFAULT) { |
if ((root->cr_method != CVS_METHOD_LOCAL) && |
|
(kflag != RCS_KWEXP_DEFAULT)) { |
strlcpy(buf, "-k", sizeof(buf)); |
strlcpy(buf, "-k", sizeof(buf)); |
strlcat(buf, koptstr, sizeof(buf)); |
strlcat(buf, koptstr, sizeof(buf)); |
if (cvs_sendarg(root, buf, 0) < 0) |
if (cvs_sendarg(root, buf, 0) < 0) |
|
|
return (0); |
return (0); |
} |
} |
|
|
int |
static int |
cvs_add_file(CVSFILE *cf, void *arg) |
cvs_add_file(CVSFILE *cf, void *arg) |
{ |
{ |
int ret; |
int ret; |
|
|
if (root->cr_method != CVS_METHOD_LOCAL) { |
if (root->cr_method != CVS_METHOD_LOCAL) { |
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
if (cf->cf_cvstat == CVS_FST_UNKNOWN) |
ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, |
ret = cvs_sendreq(root, CVS_REQ_ISMODIFIED, |
CVS_FILE_NAME(cf)); |
cf->cf_name); |
} else { |
} else { |
cvs_log(LP_INFO, "scheduling file `%s' for addition", |
cvs_log(LP_INFO, "scheduling file `%s' for addition", |
CVS_FILE_NAME(cf)); |
cf->cf_name); |
cvs_log(LP_INFO, "use `%s commit' to add this file permanently", |
cvs_log(LP_INFO, "use `%s commit' to add this file permanently", |
__progname); |
__progname); |
} |
} |