summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/diff.c22
-rw-r--r--usr.bin/rcs/rcsdiff.c26
2 files changed, 46 insertions, 2 deletions
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 428855061de..32f98d0fa8f 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.68 2005/12/01 20:36:30 niallo Exp $ */
+/* $OpenBSD: diff.c,v 1.69 2005/12/01 23:02:27 niallo Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -567,6 +567,10 @@ cvs_diff_local(CVSFILE *cf, void *arg)
RCSNUM *r1, *r2;
RCSFILE *rf;
struct cvsroot *root;
+ struct timeval tv[2], tv2[2];
+
+ memset(&tv, 0, sizeof(tv));
+ memset(&tv2, 0, sizeof(tv2));
rf = NULL;
root = CVS_DIR_ROOT(cf);
@@ -628,6 +632,8 @@ cvs_diff_local(CVSFILE *cf, void *arg)
rcs_close(rf);
return (CVS_EX_DATA);
}
+ tv[0].tv_sec = (long)rcs_rev_getdate(rf, r1);
+ tv[1].tv_sec = tv[0].tv_sec;
if (r1 != cf->cf_lrev)
rcsnum_free(r1);
@@ -652,6 +658,8 @@ cvs_diff_local(CVSFILE *cf, void *arg)
cvs_buf_free(b1);
return (CVS_EX_DATA);
}
+ tv2[0].tv_sec = (long)rcs_rev_getdate(rf, r2);
+ tv2[1].tv_sec = tv2[0].tv_sec;
cvs_printf("%s", diffargs);
cvs_printf(" -r%s", buf);
@@ -666,6 +674,8 @@ cvs_diff_local(CVSFILE *cf, void *arg)
return (CVS_EX_DATA);
}
cvs_buf_free(b1);
+ if (utimes(path_tmp1, (const struct timeval *)&tv) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
strlcpy(path_tmp2, cvs_tmpdir, sizeof(path_tmp2));
strlcat(path_tmp2, "/diff2.XXXXXXXXXX", sizeof(path_tmp2));
@@ -675,6 +685,8 @@ cvs_diff_local(CVSFILE *cf, void *arg)
return (CVS_EX_DATA);
}
cvs_buf_free(b2);
+ if (utimes(path_tmp2, (const struct timeval *)&tv2) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
cvs_diffreg(path_tmp1, path_tmp2, NULL);
(void)unlink(path_tmp1);
@@ -714,6 +726,14 @@ cvs_diffreg(const char *file1, const char *file2, BUF *out)
goto closem;
}
+ if (stat(file1, &stb1) < 0) {
+ cvs_log(LP_ERRNO, "%s", file1);
+ goto closem;
+ }
+ if (stat(file2, &stb2) < 0) {
+ cvs_log(LP_ERRNO, "%s", file2);
+ goto closem;
+ }
switch (files_differ(f1, f2)) {
case 0:
goto closem;
diff --git a/usr.bin/rcs/rcsdiff.c b/usr.bin/rcs/rcsdiff.c
index ad8bc7798f7..1862718a320 100644
--- a/usr.bin/rcs/rcsdiff.c
+++ b/usr.bin/rcs/rcsdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsdiff.c,v 1.23 2005/11/29 11:11:39 xsa Exp $ */
+/* $OpenBSD: rcsdiff.c,v 1.24 2005/12/01 23:02:27 niallo Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -179,6 +179,9 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
BUF *b1, *b2;
char rbuf[64];
struct stat st;
+ struct timeval tv[2], tv2[2];
+ memset(&tv, 0, sizeof(tv));
+ memset(&tv2, 0, sizeof(tv2));
if (stat(filename, &st) == -1) {
cvs_log(LP_ERRNO, "%s", filename);
@@ -195,12 +198,16 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
cvs_log(LP_ERR, "failed to retrieve revision");
return (-1);
}
+ tv[0].tv_sec = (long)rcs_rev_getdate(file, rev);
+ tv[1].tv_sec = tv[0].tv_sec;
if ((b2 = cvs_buf_load(filename, BUF_AUTOEXT)) == NULL) {
cvs_log(LP_ERR, "failed to load file: '%s'", filename);
cvs_buf_free(b1);
return (-1);
}
+ tv2[0].tv_sec = st.st_mtime;
+ tv2[1].tv_sec = st.st_mtime;
strlcpy(path1, rcs_tmpdir, sizeof(path1));
strlcat(path1, "/diff1.XXXXXXXXXX", sizeof(path1));
@@ -211,6 +218,8 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
return (-1);
}
cvs_buf_free(b1);
+ if (utimes(path1, (const struct timeval *)&tv) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
@@ -220,6 +229,8 @@ rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename)
return (-1);
}
cvs_buf_free(b2);
+ if (utimes(path2, (const struct timeval *)&tv2) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
cvs_diffreg(path1, path2, NULL);
(void)unlink(path1);
@@ -234,6 +245,10 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, const char *filename)
char path1[MAXPATHLEN], path2[MAXPATHLEN];
BUF *b1, *b2;
char rbuf1[64], rbuf2[64];
+ struct timeval tv[2], tv2[2];
+
+ memset(&tv, 0, sizeof(tv));
+ memset(&tv2, 0, sizeof(tv2));
rcsnum_tostr(rev1, rbuf1, sizeof(rbuf1));
if (verbose == 1)
@@ -243,6 +258,8 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, const char *filename)
cvs_log(LP_ERR, "failed to retrieve revision");
return (-1);
}
+ tv[0].tv_sec = (long)rcs_rev_getdate(file, rev1);
+ tv[1].tv_sec = tv[0].tv_sec;
rcsnum_tostr(rev2, rbuf2, sizeof(rbuf2));
if (verbose == 1)
@@ -252,6 +269,8 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, const char *filename)
cvs_log(LP_ERR, "failed to retrieve revision");
return (-1);
}
+ tv2[0].tv_sec = (long)rcs_rev_getdate(file, rev2);
+ tv2[1].tv_sec = tv2[0].tv_sec;
if (verbose == 1)
fprintf(stderr,
@@ -266,6 +285,8 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, const char *filename)
return (-1);
}
cvs_buf_free(b1);
+ if (utimes(path1, (const struct timeval *)&tv) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
strlcpy(path2, rcs_tmpdir, sizeof(path2));
strlcat(path2, "/diff2.XXXXXXXXXX", sizeof(path2));
@@ -276,6 +297,9 @@ rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, const char *filename)
}
cvs_buf_free(b2);
+ if (utimes(path2, (const struct timeval *)&tv2) < 0)
+ cvs_log(LP_ERRNO, "error setting utimes");
+
cvs_diffreg(path1, path2, NULL);
(void)unlink(path1);
(void)unlink(path2);