Hi,
This is a revised diff from the previous one I sent regarding updating
the log command to be a bit more similar to GNU cvs.
This diff now also fixes a bunch of segfaults with rare corner cases.
There are still several problems with log however, including not properly
iterating over Attic files if running with a directory as its parameter
or the fact that cvs_revision_select() is fatal happy instead of
bubbling up an error if a revision cannot be found. But those issues
will be fixed with a later diff.
.joris
Index: getlog.c
===================================================================
RCS file: /cvs/src/usr.bin/cvs/getlog.c,v
retrieving revision 1.98
diff -u -p -r1.98 getlog.c
--- getlog.c 1 Dec 2014 21:58:46 -0000 1.98
+++ getlog.c 23 Jun 2016 16:13:55 -0000
@@ -40,7 +40,7 @@
void cvs_log_local(struct cvs_file *);
static void log_rev_print(struct rcs_delta *);
static char *push_date(char *dest, const char *);
-static u_int date_select(RCSFILE *, char *);
+static int date_select(RCSFILE *, char *, u_int *);
int runflags = 0;
char *logrev = NULL;
@@ -216,9 +216,18 @@ cvs_log_local(struct cvs_file *cf)
return;
}
- if (cf->file_rcs == NULL) {
+ if (cf->file_rcs == NULL)
return;
- } else if (cf->file_status == FILE_ADDED) {
+
+ if (logrev != NULL)
+ nrev = cvs_revision_select(cf->file_rcs, logrev);
+ else if (logdate != NULL) {
+ if (date_select(cf->file_rcs, logdate, &nrev) == -1)
+ fatal("Can't parse date/time: %s", logdate);
+ } else
+ nrev = cf->file_rcs->rf_ndelta;
+
+ if (cf->file_status == FILE_ADDED) {
if (verbosity > 0)
cvs_log(LP_ERR, "%s has been added, but not committed",
cf->file_path);
@@ -230,16 +239,6 @@ cvs_log_local(struct cvs_file *cf)
return;
}
- if (logrev != NULL)
- nrev = cvs_revision_select(cf->file_rcs, logrev);
- else if (logdate != NULL) {
- if ((nrev = date_select(cf->file_rcs, logdate)) == -1) {
- cvs_log(LP_ERR, "invalid date: %s", logdate);
- return;
- }
- } else
- nrev = cf->file_rcs->rf_ndelta;
-
cvs_printf("\nRCS file: %s", cf->file_rpath);
if (cvs_cmdop != CVS_OP_RLOG)
@@ -418,8 +417,8 @@ push_date(char *dest, const char *src)
return (dest);
}
-static u_int
-date_select(RCSFILE *file, char *date)
+static int
+date_select(RCSFILE *file, char *date, u_int *cnt)
{
int i, nrev, flags;
struct rcs_delta *rdp;
@@ -427,6 +426,7 @@ date_select(RCSFILE *file, char *date)
char *first, *last, delim;
time_t firstdate, lastdate, rcsdate;
+ *cnt = 0;
nrev = 0;
args = cvs_strsplit(date, ";");
@@ -566,7 +566,8 @@ date_select(RCSFILE *file, char *date)
}
}
+ *cnt = nrev;
cvs_argv_destroy(args);
- return (nrev);
+ return 0;
}