=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/commit.c,v retrieving revision 1.17 retrieving revision 1.18 diff -c -r1.17 -r1.18 *** src/usr.bin/cvs/commit.c 2005/03/29 15:06:01 1.17 --- src/usr.bin/cvs/commit.c 2005/03/30 17:43:04 1.18 *************** *** 1,4 **** ! /* $OpenBSD: commit.c,v 1.17 2005/03/29 15:06:01 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: commit.c,v 1.18 2005/03/30 17:43:04 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 42,82 **** #include "proto.h" ! int cvs_commit_prepare (CVSFILE *, void *); ! int cvs_commit_file (CVSFILE *, void *); - - /* - * cvs_commit() - * - * Handler for the `cvs commit' command. - */ int ! cvs_commit(int argc, char **argv) { ! int i, ch, flags; ! char *mfile; ! struct cvs_flist cl; ! CVSFILE *cfp; ! struct cvsroot *root; ! flags = CF_RECURSE|CF_IGNORE|CF_SORT; ! mfile = NULL; ! TAILQ_INIT(&cl); ! ! while ((ch = getopt(argc, argv, "F:flm:Rr:")) != -1) { switch (ch) { case 'F': mfile = optarg; break; case 'f': /* XXX half-implemented */ ! flags &= ~CF_RECURSE; break; case 'l': ! flags &= ~CF_RECURSE; break; case 'm': cvs_msg = strdup(optarg); --- 42,81 ---- #include "proto.h" + static int cvs_commit_prepare(CVSFILE *, void *); + int cvs_commit_file(CVSFILE *, void *); + int cvs_commit_options(char *, int, char **, int *); + int cvs_commit_helper(void); + struct cvs_cmd_info cvs_commit = { + cvs_commit_options, + NULL, + cvs_commit_file, + NULL, + cvs_commit_helper, + CF_RECURSE | CF_IGNORE | CF_SORT, + CVS_REQ_CI, + CVS_CMD_NEEDLOG | CVS_CMD_SENDDIR | CVS_CMD_SENDARGS2 + }; ! static char *mfile = NULL; int ! cvs_commit_options(char *opt, int argc, char **argv, int *arg) { ! int ch; ! while ((ch = getopt(argc, argv, opt)) != -1) { switch (ch) { case 'F': mfile = optarg; break; case 'f': /* XXX half-implemented */ ! cvs_commit.file_flags &= ~CF_RECURSE; break; case 'l': ! cvs_commit.file_flags &= ~CF_RECURSE; break; case 'm': cvs_msg = strdup(optarg); *************** *** 86,92 **** } break; case 'R': ! flags |= CF_RECURSE; break; default: return (EX_USAGE); --- 85,91 ---- } break; case 'R': ! cvs_commit.file_flags |= CF_RECURSE; break; default: return (EX_USAGE); *************** *** 101,117 **** if ((mfile != NULL) && (cvs_msg = cvs_logmsg_open(mfile)) == NULL) return (EX_DATAERR); ! argc -= optind; ! argv += optind; ! if (argc == 0) { ! cvs_files = cvs_file_get(".", flags); ! } else { ! cvs_files = cvs_file_getspec(argv, argc, flags); ! } ! if (cvs_files == NULL) ! return (EX_DATAERR); cvs_file_examine(cvs_files, cvs_commit_prepare, &cl); if (TAILQ_EMPTY(&cl)) return (0); --- 100,116 ---- if ((mfile != NULL) && (cvs_msg = cvs_logmsg_open(mfile)) == NULL) return (EX_DATAERR); ! *arg = optind; ! return (0); ! } ! int ! cvs_commit_helper(void) ! { ! struct cvs_flist cl; ! CVSFILE *cfp; + TAILQ_INIT(&cl); cvs_file_examine(cvs_files, cvs_commit_prepare, &cl); if (TAILQ_EMPTY(&cl)) return (0); *************** *** 129,161 **** if (cvs_msg == NULL) return (1); - root = CVS_DIR_ROOT(cvs_files); - if (root == NULL) { - cvs_log(LP_ERR, - "No CVSROOT specified! Please use the `-d' option"); - cvs_log(LP_ERR, - "or set the CVSROOT environment variable."); - return (EX_USAGE); - } - if ((root->cr_method != CVS_METHOD_LOCAL) && - ((cvs_connect(root) < 0) || (cvs_logmsg_send(root, cvs_msg) < 0))) - return (EX_PROTOCOL); - - cvs_file_examine(cvs_files, cvs_commit_file, &cl); - - if (root->cr_method != CVS_METHOD_LOCAL) { - if (cvs_senddir(root, cvs_files) < 0) - return (EX_PROTOCOL); - for (i = 0; i < argc; i++) - if (cvs_sendarg(root, argv[i], 0) < 0) - return (EX_PROTOCOL); - if (cvs_sendreq(root, CVS_REQ_CI, NULL) < 0) - return (EX_PROTOCOL); - } - return (0); } - /* * cvs_commit_prepare() --- 128,135 ----