=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/commit.c,v retrieving revision 1.65 retrieving revision 1.66 diff -c -r1.65 -r1.66 *** src/usr.bin/cvs/commit.c 2006/05/30 21:32:52 1.65 --- src/usr.bin/cvs/commit.c 2006/05/31 01:26:21 1.66 *************** *** 1,4 **** ! /* $OpenBSD: commit.c,v 1.65 2006/05/30 21:32:52 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * --- 1,4 ---- ! /* $OpenBSD: commit.c,v 1.66 2006/05/31 01:26:21 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * *************** *** 150,159 **** cvs_commit_local(struct cvs_file *cf) { BUF *b; ! int l, isadded; char *d, *f, rbuf[24]; CVSENTRIES *entlist; ! char *attic, *repo; cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path); cvs_file_classify(cf, NULL, 0); --- 150,159 ---- cvs_commit_local(struct cvs_file *cf) { BUF *b; ! int l, openflags, rcsflags; char *d, *f, rbuf[24]; CVSENTRIES *entlist; ! char *attic, *repo, *rcsfile; cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path); cvs_file_classify(cf, NULL, 0); *************** *** 162,180 **** fatal("cvs_commit_local: '%s' is not a file", cf->file_path); if (cf->file_status == FILE_MODIFIED || ! cf->file_status == FILE_REMOVED) rcsnum_tostr(cf->file_rcs->rf_head, rbuf, sizeof(rbuf)); else strlcpy(rbuf, "Non-existent", sizeof(rbuf)); ! isadded = (cf->file_status == FILE_ADDED && cf->file_rcs == NULL); ! if (isadded) { ! cf->repo_fd = open(cf->file_rpath, O_CREAT|O_TRUNC|O_WRONLY); if (cf->repo_fd < 0) fatal("cvs_commit_local: %s", strerror(errno)); cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd, ! RCS_CREATE, 0600); if (cf->file_rcs == NULL) fatal("cvs_commit_local: failed to create RCS file " "for %s", cf->file_path); --- 162,214 ---- fatal("cvs_commit_local: '%s' is not a file", cf->file_path); if (cf->file_status == FILE_MODIFIED || ! cf->file_status == FILE_REMOVED || (cf->file_status == FILE_ADDED ! && cf->file_rcs != NULL && cf->file_rcs->rf_dead == 1)) rcsnum_tostr(cf->file_rcs->rf_head, rbuf, sizeof(rbuf)); else strlcpy(rbuf, "Non-existent", sizeof(rbuf)); ! if (cf->file_status == FILE_ADDED) { ! rcsflags = RCS_CREATE; ! openflags = O_CREAT | O_TRUNC | O_WRONLY; ! if (cf->file_rcs != NULL) { ! if (cf->file_rcs->rf_inattic == 0) ! cvs_log(LP_ERR, "warning: expected %s " ! "to be in the Attic", cf->file_path); ! ! if (cf->file_rcs->rf_dead == 0) ! cvs_log(LP_ERR, "warning: expected %s " ! "to be dead", cf->file_path); ! ! rcsfile = xmalloc(MAXPATHLEN); ! repo = xmalloc(MAXPATHLEN); ! cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); ! l = snprintf(rcsfile, MAXPATHLEN, "%s/%s%s", ! repo, cf->file_name, RCS_FILE_EXT); ! if (l == -1 || l >= MAXPATHLEN) ! fatal("cvs_commit_local: overflow"); ! ! if (rename(cf->file_rpath, rcsfile) == -1) ! fatal("cvs_commit_local: failed to move %s " ! "outside the Attic: %s", cf->file_path, ! strerror(errno)); ! ! xfree(cf->file_rpath); ! cf->file_rpath = xstrdup(rcsfile); ! xfree(rcsfile); ! xfree(repo); ! ! rcsflags = RCS_READ | RCS_PARSE_FULLY; ! openflags = O_RDONLY; ! rcs_close(cf->file_rcs); ! } ! ! cf->repo_fd = open(cf->file_rpath, openflags); if (cf->repo_fd < 0) fatal("cvs_commit_local: %s", strerror(errno)); cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd, ! rcsflags, 0600); if (cf->file_rcs == NULL) fatal("cvs_commit_local: failed to create RCS file " "for %s", cf->file_path); *************** *** 184,190 **** cvs_printf("%s <- %s\n", cf->file_rpath, cf->file_path); cvs_printf("old revision: %s; ", rbuf); ! if (isadded == 0) d = commit_diff_file(cf); if (cf->file_status == FILE_REMOVED) { --- 218,224 ---- cvs_printf("%s <- %s\n", cf->file_rpath, cf->file_path); cvs_printf("old revision: %s; ", rbuf); ! if (cf->file_status != FILE_ADDED) d = commit_diff_file(cf); if (cf->file_status == FILE_REMOVED) { *************** *** 199,205 **** cvs_buf_putc(b, '\0'); f = cvs_buf_release(b); ! if (isadded == 0) { if (rcs_deltatext_set(cf->file_rcs, cf->file_rcs->rf_head, d) == -1) fatal("cvs_commit_local: failed to set delta"); --- 233,239 ---- cvs_buf_putc(b, '\0'); f = cvs_buf_release(b); ! if (cf->file_status != FILE_ADDED) { if (rcs_deltatext_set(cf->file_rcs, cf->file_rcs->rf_head, d) == -1) fatal("cvs_commit_local: failed to set delta"); *************** *** 213,219 **** xfree(f); ! if (isadded == 0) xfree(d); if (cf->file_status == FILE_REMOVED) { --- 247,253 ---- xfree(f); ! if (cf->file_status != FILE_ADDED) xfree(d); if (cf->file_status == FILE_REMOVED) { *************** *** 227,233 **** if (cf->file_status == FILE_REMOVED) { strlcpy(rbuf, "Removed", sizeof(rbuf)); } else if (cf->file_status == FILE_ADDED) { ! if (cf->file_rcs->rf_dead == 0) strlcpy(rbuf, "Initial Revision", sizeof(rbuf)); else rcsnum_tostr(cf->file_rcs->rf_head, --- 261,267 ---- if (cf->file_status == FILE_REMOVED) { strlcpy(rbuf, "Removed", sizeof(rbuf)); } else if (cf->file_status == FILE_ADDED) { ! if (cf->file_rcs->rf_dead == 1) strlcpy(rbuf, "Initial Revision", sizeof(rbuf)); else rcsnum_tostr(cf->file_rcs->rf_head,