diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-10-13 22:54:47 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2005-10-13 22:54:47 +0000 |
commit | cd4adc73212ec0a939417d827d4e4fa0a0274a4d (patch) | |
tree | 255cf7b823c117d9a3ccc9cf13fabdcd312183c2 /usr.bin | |
parent | d6c18017b5f79c86080812c1089db04151fc138b (diff) |
- implement bare `-d' option; this sets the check-in date and time
to be that of the working file's last modification time.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/rcs/ci.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index c2783d54829..c11ffb51e91 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.24 2005/10/13 12:35:30 joris Exp $ */ +/* $OpenBSD: ci.c,v 1.25 2005/10/13 22:54:46 niallo Exp $ */ /* * Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -47,6 +47,9 @@ #define LOCK_LOCK 1 #define LOCK_UNLOCK 2 +#define DATE_NOW -1 +#define DATE_MTIME -2 + static char * checkin_diff_file(RCSFILE *, RCSNUM *, const char *); static char * checkin_getlogmsg(char *, char *, RCSNUM *, RCSNUM *); @@ -69,7 +72,7 @@ checkin_main(int argc, char **argv) { int i, ch, flags, lkmode, interactive, rflag, status; mode_t fmode; - time_t date = -1; + time_t date = DATE_NOW; RCSFILE *file; RCSNUM *frev, *newrev; char fpath[MAXPATHLEN]; @@ -89,10 +92,12 @@ checkin_main(int argc, char **argv) exit(1); } - while ((ch = rcs_getopt(argc, argv, "j:l::M:N:qu::d:r::m:k:V")) != -1) { + while ((ch = rcs_getopt(argc, argv, "j:l::M:N:qu::d::r::m:k:V")) != -1) { switch (ch) { case 'd': - if ((date = cvs_date_parse(rcs_optarg)) <= 0) { + if (rcs_optarg == NULL) + date = DATE_MTIME; + else if ((date = cvs_date_parse(rcs_optarg)) <= 0) { cvs_log(LP_ERR, "invalide date"); exit(1); } @@ -242,6 +247,19 @@ checkin_main(int argc, char **argv) exit (1); } /* + * Set the date of the revision to be the last modification time + * of the working file if -d is specified without an argument. + */ + if (date == DATE_MTIME) { + struct stat sb; + if (stat(argv[i], &sb) != 0) { + cvs_log(LP_ERRNO, "failed to stat: `%s'", argv[i]); + rcs_close(file); + continue; + } + date = (time_t)sb.st_mtimespec.tv_sec; + } + /* * Now add our new revision */ if (rcs_rev_add(file, (newrev == NULL ? RCS_HEAD_REV : newrev), |