summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2006-05-30 04:20:28 +0000
committerJoris Vink <joris@cvs.openbsd.org>2006-05-30 04:20:28 +0000
commitb5866255cbc8b33c27bebbdc509c8df0916406df (patch)
treeda271865c540b22290252cd65d9d7da768175490 /usr.bin/cvs
parentb44b7df190d632366b0cdc29fbada19ef4760886 (diff)
the moment we are done commiting a removed file, move the RCS file
into the Attic and out of our way.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/commit.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 4aeef771879..80a78dae576 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.63 2006/05/28 10:15:35 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.64 2006/05/30 04:20:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -150,13 +150,17 @@ void
cvs_commit_local(struct cvs_file *cf)
{
BUF *b;
- int isadded;
+ 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, 0);
+ if (cf->file_type != CVS_FILE)
+ 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));
@@ -248,6 +252,29 @@ cvs_commit_local(struct cvs_file *cf)
entlist = cvs_ent_open(cf->file_wd);
cvs_ent_remove(entlist, cf->file_name);
cvs_ent_close(entlist, ENT_SYNC);
+
+ repo = xmalloc(MAXPATHLEN);
+ attic = xmalloc(MAXPATHLEN);
+ cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
+
+ l = snprintf(attic, MAXPATHLEN, "%s/%s", repo, CVS_PATH_ATTIC);
+ if (l == -1 || l >= MAXPATHLEN)
+ fatal("cvs_commit_local: overflow");
+
+ if (mkdir(attic, 0755) == -1 && errno != EEXIST)
+ fatal("cvs_commit_local: failed to create Attic");
+
+ l = snprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo,
+ CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT);
+ if (l == -1 || l >= MAXPATHLEN)
+ fatal("cvs_commit_local: overflow");
+
+ if (rename(cf->file_rpath, attic) == -1)
+ fatal("cvs_commit_local: failed to move %s to Attic",
+ cf->file_path);
+
+ xfree(repo);
+ xfree(attic);
}
cvs_printf("done\n");