From: Junio C Hamano <junkio@cox.net>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Update tests to use test-chmtime
Date: Sat, 24 Feb 2007 23:09:43 -0800 [thread overview]
Message-ID: <7vzm72vhl4.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <11723651934078-git-send-email-normalperson@yhbt.net> (Eric Wong's message of "Sat, 24 Feb 2007 16:59:52 -0800")
Eric Wong <normalperson@yhbt.net> writes:
> -case "$(date -d @11111111 +%s 2>/dev/null)" in
> -11111111)
> ...
> - touch -m -t "$predate1" $rr/preimage
> - touch -m -t "$predate2" $rr2/preimage
> ...
> -esac
> +now=$(date +%s)
> +almost_15_days_ago=$(($now+60-15*86400))
> +just_over_15_days_ago=$(($now-1-15*86400))
> +almost_60_days_ago=$(($now+60-60*86400))
> +just_over_60_days_ago=$(($now-1-60*86400))
> +
> +test-chmtime =$almost_60_days_ago $rr/preimage
> +test-chmtime =$almost_15_days_ago $rr2/preimage
Very nice.
I've been wanting to get rid of this part for quite a while.
However, is '+%s' output portable enough for this change to be
an improvement?
I would suggest changing "test-chmtime =-200 file" to set the
mtime of the file to 200 seconds in the past, relative to
present.
---
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index d5bb6ec..639d45f 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -112,11 +112,10 @@ rr2=.git/rr-cache/$sha2
mkdir $rr2
echo Hello > $rr2/preimage
-now=$(date +%s)
-almost_15_days_ago=$(($now+60-15*86400))
-just_over_15_days_ago=$(($now-1-15*86400))
-almost_60_days_ago=$(($now+60-60*86400))
-just_over_60_days_ago=$(($now-1-60*86400))
+almost_15_days_ago=$((60-15*86400))
+just_over_15_days_ago=$((-1-15*86400))
+almost_60_days_ago=$((60-60*86400))
+just_over_60_days_ago=$((-1-60*86400))
test-chmtime =$almost_60_days_ago $rr/preimage
test-chmtime =$almost_15_days_ago $rr2/preimage
diff --git a/test-chmtime.c b/test-chmtime.c
index 69b3ba9..2a1d00d 100644
--- a/test-chmtime.c
+++ b/test-chmtime.c
@@ -1,7 +1,7 @@
#include "git-compat-util.h"
#include <utime.h>
-static const char usage_str[] = "(+|=|-)<seconds> <file_1> [<file_2>]";
+static const char usage_str[] = "(+|=|-)<seconds> <file_1>...";
int main(int argc, const char *argv[])
{
@@ -19,6 +19,10 @@ int main(int argc, const char *argv[])
fprintf(stderr, "Not a base-10 integer: %s\n", argv[1] + 1);
goto usage;
}
+ if (set_eq && set_time < 0) {
+ time_t now = time(NULL);
+ set_time += now;
+ }
for (i = 2; i < argc; i++) {
struct stat sb;
next prev parent reply other threads:[~2007-02-25 7:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-25 0:59 [PATCH] Add test-chmtime: a utility to change mtime on files Eric Wong
2007-02-25 0:59 ` [PATCH] Update tests to use test-chmtime Eric Wong
2007-02-25 7:09 ` Junio C Hamano [this message]
2007-02-25 15:20 ` Johannes Schindelin
2007-02-25 19:23 ` Eric Wong
2007-02-25 19:33 ` Junio C Hamano
2007-02-25 1:27 ` [PATCH] Add test-chmtime: a utility to change mtime on files Johannes Schindelin
2007-02-25 2:15 ` Eric Wong
2007-02-25 2:18 ` [PATCH (try 2)] " Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vzm72vhl4.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).