Annotation of src/usr.bin/cvs/add.c, Revision 1.43
1.43 ! joris 1: /* $OpenBSD$ */
1.1 jfb 2: /*
1.43 ! joris 3: * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.1 jfb 4: *
1.43 ! joris 5: * Permission to use, copy, modify, and distribute this software for any
! 6: * purpose with or without fee is hereby granted, provided that the above
! 7: * copyright notice and this permission notice appear in all copies.
1.1 jfb 8: *
1.43 ! joris 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 jfb 16: */
17:
1.37 xsa 18: #include "includes.h"
1.1 jfb 19:
20: #include "cvs.h"
1.43 ! joris 21: #include "diff.h"
1.1 jfb 22: #include "log.h"
1.2 jfb 23: #include "proto.h"
1.1 jfb 24:
1.43 ! joris 25: int cvs_add(int, char **);
! 26: void cvs_add_local(struct cvs_file *);
1.1 jfb 27:
1.43 ! joris 28: char *logmsg;
1.21 jfb 29:
30: struct cvs_cmd cvs_cmd_add = {
31: CVS_OP_ADD, CVS_REQ_ADD, "add",
32: { "ad", "new" },
1.43 ! joris 33: "Add a new file or directory to the repository",
! 34: "[-m message] ...",
! 35: "m",
1.21 jfb 36: NULL,
1.43 ! joris 37: cvs_add
1.15 joris 38: };
1.3 jfb 39:
1.43 ! joris 40: int
! 41: cvs_add(int argc, char **argv)
1.1 jfb 42: {
1.15 joris 43: int ch;
1.43 ! joris 44: int flags;
! 45: char *arg = ".";
! 46: struct cvs_recursion cr;
1.1 jfb 47:
1.43 ! joris 48: flags = CR_RECURSE_DIRS | CR_REPO;
1.1 jfb 49:
1.43 ! joris 50: while ((ch = getopt(argc, argv, cvs_cmd_add.cmd_opts)) != -1) {
1.1 jfb 51: switch (ch) {
52: case 'm':
1.43 ! joris 53: logmsg = xstrdup(optarg);
1.1 jfb 54: break;
55: default:
1.43 ! joris 56: fatal("%s", cvs_cmd_add.cmd_synopsis);
1.1 jfb 57: }
58: }
59:
1.43 ! joris 60: argc -= optind;
! 61: argv += optind;
1.28 xsa 62:
1.43 ! joris 63: cr.enterdir = NULL;
! 64: cr.leavedir = NULL;
! 65: cr.local = cvs_add_local;
! 66: cr.remote = NULL;
! 67: cr.flags = flags;
! 68:
! 69: if (argc > 0)
! 70: cvs_file_run(argc, argv, &cr);
! 71: else
! 72: cvs_file_run(1, &arg, &cr);
1.3 jfb 73:
74: return (0);
75: }
76:
1.43 ! joris 77: void
! 78: cvs_add_local(struct cvs_file *cf)
1.3 jfb 79: {
1.43 ! joris 80: cvs_log(LP_TRACE, "cvs_add_local(%s)", cf->file_path);
1.3 jfb 81:
1.43 ! joris 82: cvs_file_classify(cf, 0);
1.10 xsa 83:
1.43 ! joris 84: switch (cf->file_status) {
! 85: case FILE_ADDED:
! 86: cvs_log(LP_NOTICE, "%s has already been entered",
! 87: cf->file_path);
! 88: break;
! 89: case FILE_UNKNOWN:
! 90: cvs_log(LP_NOTICE, "%s is unknown to us so far",
! 91: cf->file_path);
! 92: break;
! 93: default:
! 94: break;
1.1 jfb 95: }
96: }