summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiall O'Higgins <niallo@cvs.openbsd.org>2006-03-05 17:17:28 +0000
committerNiall O'Higgins <niallo@cvs.openbsd.org>2006-03-05 17:17:28 +0000
commitf4281f37fc4f53dd7decf9631f3070382505d97c (patch)
tree94b98c120bb2f2d075d48c964459545e3d3f562d /usr.bin
parent62c49de61ea368ae4ac38740b6746db5d9ca921c (diff)
GNU ci(1) doesn't allow dates younger than HEAD, neither on the command
line via -d<date> nor via stat mtime on the working file (plain -d). add a check for this in checkin_update(), abort and warn the user should we encounter such a situation.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/ci.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index e468bcf9220..57cc5d1c086 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.103 2006/03/05 15:47:17 niallo Exp $ */
+/* $OpenBSD: ci.c,v 1.104 2006/03/05 17:17:27 niallo Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -460,6 +460,34 @@ checkin_update(struct checkin_params *pb)
return (-1);
}
+ /*
+ * Set the date of the revision to be the last modification
+ * time of the working file if -d has no argument.
+ */
+ if (pb->date == DATE_MTIME
+ && (checkin_mtimedate(pb) < 0))
+ return (-1);
+
+ /* Date from argv/mtime must be more recent than HEAD */
+ if (pb->date != DATE_NOW) {
+ time_t head_date = rcs_rev_getdate(pb->file, pb->frev);
+ if (pb->date <= head_date) {
+ char *head_date_str, *tdate;
+ head_date_str = xstrdup(ctime(&head_date));
+ head_date_str[strlen(head_date_str) - 1] = '\0';
+ tdate = xstrdup(ctime(&pb->date));
+ tdate[strlen(tdate) - 1] = '\0';
+ cvs_log(LP_ERR,
+ "%s: Date %s preceeds %s in revision %s",
+ pb->file->rf_path, tdate, head_date_str,
+ rcsnum_tostr(pb->frev, numb2, sizeof(numb2)));
+ rcs_close(pb->file);
+ xfree(head_date_str);
+ xfree(tdate);
+ return (-1);
+ }
+ }
+
/* Load file contents */
if ((bp = cvs_buf_load(pb->filename, BUF_AUTOEXT)) == NULL) {
cvs_log(LP_ERR, "failed to load '%s'", pb->filename);
@@ -502,14 +530,6 @@ checkin_update(struct checkin_params *pb)
if (rcs_deltatext_set(pb->file, pb->frev, pb->deltatext) == -1)
fatal("failed to set new rd_text for head rev");
- /*
- * Set the date of the revision to be the last modification
- * time of the working file if -d has no argument.
- */
- if (pb->date == DATE_MTIME
- && (checkin_mtimedate(pb) < 0))
- return (-1);
-
/* Now add our new revision */
if (rcs_rev_add(pb->file,
(pb->newrev == NULL ? RCS_HEAD_REV : pb->newrev),