* [PATCH 0/2] Date test code clean-up
@ 2019-09-09 1:47 Stephen P. Smith
2019-09-09 1:47 ` [PATCH 1/2] Quit passing 'now' to date code Stephen P. Smith
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-09 1:47 UTC (permalink / raw)
To: git
As part of a previous patch submission[1], a cleanup patch was
suggested to remove a now unnecessary passing of a date environment
variable to the production code.
While the two patches in the set could easily be submitted as a single
patch, I split the removal of the getenv() call into a second
patch. I did that to make the comment about the initialization of `x`
more localized to the change.
[1] https://public-inbox.org/git/xmqq5zuge2y7.fsf@gitster-ct.c.googlers.com
Stephen P. Smith (2):
Quit passing 'now' to date code
test_date.c: Remove reference to GIT_TEST_DATE_NOW
cache.h | 5 ++---
date.c | 27 +++++++++++++--------------
t/helper/test-date.c | 27 +++++++++------------------
3 files changed, 24 insertions(+), 35 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] Quit passing 'now' to date code
2019-09-09 1:47 [PATCH 0/2] Date test code clean-up Stephen P. Smith
@ 2019-09-09 1:47 ` Stephen P. Smith
2019-09-09 17:28 ` Jeff King
2019-09-09 1:47 ` [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-09 1:47 UTC (permalink / raw)
To: git
As part of a previous patch set, the get_time() function was added to
date.c eliminating the need to pass a `now` parameter from the test
code.
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
---
cache.h | 5 ++---
date.c | 27 +++++++++++++--------------
t/helper/test-date.c | 26 +++++++++-----------------
3 files changed, 24 insertions(+), 34 deletions(-)
diff --git a/cache.h b/cache.h
index b1da1ab08f..48d4287aa7 100644
--- a/cache.h
+++ b/cache.h
@@ -1516,8 +1516,7 @@ struct date_mode {
struct date_mode *date_mode_from_type(enum date_mode_type type);
const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
-void show_date_relative(timestamp_t time, const struct timeval *now,
- struct strbuf *timebuf);
+void show_date_relative(timestamp_t time, struct strbuf *timebuf);
void show_date_human(timestamp_t time, int tz, const struct timeval *now,
struct strbuf *timebuf);
int parse_date(const char *date, struct strbuf *out);
@@ -1526,7 +1525,7 @@ int parse_expiry_date(const char *date, timestamp_t *timestamp);
void datestamp(struct strbuf *out);
#define approxidate(s) approxidate_careful((s), NULL)
timestamp_t approxidate_careful(const char *, int *);
-timestamp_t approxidate_relative(const char *date, const struct timeval *now);
+timestamp_t approxidate_relative(const char *date);
void parse_date_format(const char *format, struct date_mode *mode);
int date_overflows(timestamp_t date);
diff --git a/date.c b/date.c
index 8126146c50..041db7db4e 100644
--- a/date.c
+++ b/date.c
@@ -128,16 +128,17 @@ static void get_time(struct timeval *now)
gettimeofday(now, NULL);
}
-void show_date_relative(timestamp_t time,
- const struct timeval *now,
- struct strbuf *timebuf)
+void show_date_relative(timestamp_t time, struct strbuf *timebuf)
{
+ struct timeval now;
timestamp_t diff;
- if (now->tv_sec < time) {
+
+ get_time(&now);
+ if (now.tv_sec < time) {
strbuf_addstr(timebuf, _("in the future"));
return;
}
- diff = now->tv_sec - time;
+ diff = now.tv_sec - time;
if (diff < 90) {
strbuf_addf(timebuf,
Q_("%"PRItime" second ago", "%"PRItime" seconds ago", diff), diff);
@@ -240,9 +241,7 @@ static void show_date_normal(struct strbuf *buf, timestamp_t time, struct tm *tm
/* Show "today" times as just relative times */
if (hide.wday) {
- struct timeval now;
- get_time(&now);
- show_date_relative(time, &now, buf);
+ show_date_relative(time, buf);
return;
}
@@ -313,11 +312,8 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
}
if (mode->type == DATE_RELATIVE) {
- struct timeval now;
-
strbuf_reset(&timebuf);
- get_time(&now);
- show_date_relative(time, &now, &timebuf);
+ show_date_relative(time, &timebuf);
return timebuf.buf;
}
@@ -1288,15 +1284,18 @@ static timestamp_t approxidate_str(const char *date,
return (timestamp_t)update_tm(&tm, &now, 0);
}
-timestamp_t approxidate_relative(const char *date, const struct timeval *tv)
+timestamp_t approxidate_relative(const char *date)
{
+ struct timeval tv;
timestamp_t timestamp;
int offset;
int errors = 0;
if (!parse_date_basic(date, ×tamp, &offset))
return timestamp;
- return approxidate_str(date, tv, &errors);
+
+ get_time(&tv);
+ return approxidate_str(date, (const struct timeval *) &tv, &errors);
}
timestamp_t approxidate_careful(const char *date, int *error_ret)
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 585347ea48..deb5869343 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -12,13 +12,13 @@ static const char *usage_msg = "\n"
" test-tool date is64bit\n"
" test-tool date time_t-is64bit\n";
-static void show_relative_dates(const char **argv, struct timeval *now)
+static void show_relative_dates(const char **argv)
{
struct strbuf buf = STRBUF_INIT;
for (; *argv; argv++) {
time_t t = atoi(*argv);
- show_date_relative(t, now, &buf);
+ show_date_relative(t, &buf);
printf("%s -> %s\n", *argv, buf.buf);
}
strbuf_release(&buf);
@@ -74,20 +74,20 @@ static void parse_dates(const char **argv)
strbuf_release(&result);
}
-static void parse_approxidate(const char **argv, struct timeval *now)
+static void parse_approxidate(const char **argv)
{
for (; *argv; argv++) {
timestamp_t t;
- t = approxidate_relative(*argv, now);
+ t = approxidate_relative(*argv);
printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601)));
}
}
-static void parse_approx_timestamp(const char **argv, struct timeval *now)
+static void parse_approx_timestamp(const char **argv)
{
for (; *argv; argv++) {
timestamp_t t;
- t = approxidate_relative(*argv, now);
+ t = approxidate_relative(*argv);
printf("%s -> %"PRItime"\n", *argv, t);
}
}
@@ -103,22 +103,14 @@ static void getnanos(const char **argv)
int cmd__date(int argc, const char **argv)
{
- struct timeval now;
const char *x;
-
x = getenv("GIT_TEST_DATE_NOW");
- if (x) {
- now.tv_sec = atoi(x);
- now.tv_usec = 0;
- }
- else
- gettimeofday(&now, NULL);
argv++;
if (!*argv)
usage(usage_msg);
if (!strcmp(*argv, "relative"))
- show_relative_dates(argv+1, &now);
+ show_relative_dates(argv+1);
else if (!strcmp(*argv, "human"))
show_human_dates(argv+1);
else if (skip_prefix(*argv, "show:", &x))
@@ -126,9 +118,9 @@ int cmd__date(int argc, const char **argv)
else if (!strcmp(*argv, "parse"))
parse_dates(argv+1);
else if (!strcmp(*argv, "approxidate"))
- parse_approxidate(argv+1, &now);
+ parse_approxidate(argv+1);
else if (!strcmp(*argv, "timestamp"))
- parse_approx_timestamp(argv+1, &now);
+ parse_approx_timestamp(argv+1);
else if (!strcmp(*argv, "getnanos"))
getnanos(argv+1);
else if (!strcmp(*argv, "is64bit"))
--
2.23.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW
2019-09-09 1:47 [PATCH 0/2] Date test code clean-up Stephen P. Smith
2019-09-09 1:47 ` [PATCH 1/2] Quit passing 'now' to date code Stephen P. Smith
@ 2019-09-09 1:47 ` Stephen P. Smith
2019-09-09 17:29 ` Jeff King
2019-09-09 18:32 ` [PATCH 0/2] Date test code clean-up Junio C Hamano
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
3 siblings, 1 reply; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-09 1:47 UTC (permalink / raw)
To: git
Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
The intialization of variable x with the value from GIT_TEST_DATE_NOW
is unneeded since x is initalized by skip_prefix().
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
---
t/helper/test-date.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index deb5869343..099eff4f0f 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -104,7 +104,6 @@ static void getnanos(const char **argv)
int cmd__date(int argc, const char **argv)
{
const char *x;
- x = getenv("GIT_TEST_DATE_NOW");
argv++;
if (!*argv)
--
2.23.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Quit passing 'now' to date code
2019-09-09 1:47 ` [PATCH 1/2] Quit passing 'now' to date code Stephen P. Smith
@ 2019-09-09 17:28 ` Jeff King
0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2019-09-09 17:28 UTC (permalink / raw)
To: Stephen P. Smith; +Cc: git
On Sun, Sep 08, 2019 at 06:47:10PM -0700, Stephen P. Smith wrote:
> As part of a previous patch set, the get_time() function was added to
> date.c eliminating the need to pass a `now` parameter from the test
> code.
I'm glad to see this cleanup. I think it is worth explaining a bit more,
though, why this hunk in particular:
> @@ -103,22 +103,14 @@ static void getnanos(const char **argv)
>
> int cmd__date(int argc, const char **argv)
> {
> - struct timeval now;
> const char *x;
> -
> x = getenv("GIT_TEST_DATE_NOW");
> - if (x) {
> - now.tv_sec = atoi(x);
> - now.tv_usec = 0;
> - }
> - else
> - gettimeofday(&now, NULL);
...is doing the right thing, since it was the site that actually used
the parameters that are being deleted. Maybe something like:
Commit b841d4ff43 (Add `human` format to test-tool, 2019-01-28) added
a get_time() function which allows $GIT_TEST_DATE_NOW in the
environment to override the current time. So we no longer need to
interpret that variable in cmd__date().
Likewise, we can stop passing the "now" parameter down through the
date functions, since nobody uses them. Note that we do need to make
sure all of the previous callers that took a "now" parameter are
correctly using get_time().
which I think explains all of the hunks.
-Peff
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW
2019-09-09 1:47 ` [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
@ 2019-09-09 17:29 ` Jeff King
2019-09-09 19:44 ` Junio C Hamano
0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2019-09-09 17:29 UTC (permalink / raw)
To: Stephen P. Smith; +Cc: git
On Sun, Sep 08, 2019 at 06:47:11PM -0700, Stephen P. Smith wrote:
> Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
> The intialization of variable x with the value from GIT_TEST_DATE_NOW
> is unneeded since x is initalized by skip_prefix().
It took me a minute to understand what this second sentence meant. I'd
have actually expected "x" to go away, looking at the diff context.
Maybe a more clear explanation would be: We can't get rid of the "x"
variable, since it serves as a generic scratch variable for parsing
later in the function.
(I'd also probably have just rolled this into patch 1, but I'm OK with
it either way).
-Peff
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/2] Date test code clean-up
2019-09-09 1:47 [PATCH 0/2] Date test code clean-up Stephen P. Smith
2019-09-09 1:47 ` [PATCH 1/2] Quit passing 'now' to date code Stephen P. Smith
2019-09-09 1:47 ` [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
@ 2019-09-09 18:32 ` Junio C Hamano
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
3 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2019-09-09 18:32 UTC (permalink / raw)
To: Stephen P. Smith; +Cc: git
"Stephen P. Smith" <ischis2@cox.net> writes:
> As part of a previous patch submission[1], a cleanup patch was
> suggested to remove a now unnecessary passing of a date environment
> variable to the production code.
It looks like that the idea to realize that get_time() that is aware
of GIT_TEST_DATE_NOW is always called before functions like
show_date_relative(), approxidate_str() and approxidate_careful(),
and arrange it to be called in the lower level of the callchain,
which makes sense to me.
Thanks for tying the loose end.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW
2019-09-09 17:29 ` Jeff King
@ 2019-09-09 19:44 ` Junio C Hamano
0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2019-09-09 19:44 UTC (permalink / raw)
To: Jeff King; +Cc: Stephen P. Smith, git
Jeff King <peff@peff.net> writes:
> On Sun, Sep 08, 2019 at 06:47:11PM -0700, Stephen P. Smith wrote:
>
>> Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
>> The intialization of variable x with the value from GIT_TEST_DATE_NOW
>> is unneeded since x is initalized by skip_prefix().
>
> It took me a minute to understand what this second sentence meant. I'd
> have actually expected "x" to go away, looking at the diff context.
>
> Maybe a more clear explanation would be: We can't get rid of the "x"
> variable, since it serves as a generic scratch variable for parsing
> later in the function.
>
> (I'd also probably have just rolled this into patch 1, but I'm OK with
> it either way).
Thanks for saying everything ;-) I have nothing to add.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/2] Date test code clean-up
2019-09-09 1:47 [PATCH 0/2] Date test code clean-up Stephen P. Smith
` (2 preceding siblings ...)
2019-09-09 18:32 ` [PATCH 0/2] Date test code clean-up Junio C Hamano
@ 2019-09-12 4:11 ` Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 1/2] Quit passing 'now' to date code Stephen P. Smith
` (2 more replies)
3 siblings, 3 replies; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-12 4:11 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
As part of a previous patch submission[1], a cleanup patch was
suggested to remove a now unnecessary passing of a date environment
variable to the production code.
While the two patches in the set could easily be submitted as a single
patch, I split the removal of the getenv() call into a second
patch. I did that to make the comment about the initialization of `x`
more localized to the change.
[1] https://public-inbox.org/git/xmqq5zuge2y7.fsf@gitster-ct.c.googlers.com
Range Diff:
1: f4170ad553 ! 1: e2b8322d58 Quit passing 'now' to date code
@@ Metadata
## Commit message ##
Quit passing 'now' to date code
- As part of a previous patch set, the get_time() function was added to
- date.c eliminating the need to pass a `now` parameter from the test
- code.
+ Commit b841d4ff43 (Add `human` format to test-tool, 2019-01-28) added
+ a get_time() function which allows $GIT_TEST_DATE_NOW in the
+ environment to override the current time. So we no longer need to
+ interpret that variable in cmd__date().
- This patch removes the unneeded `now` parameter.
+ Therefore, we can stop passing the "now" parameter down through the
+ date functions, since nobody uses them. Note that we do need to make
+ sure all of the previous callers that took a "now" parameter are
+ correctly using get_time().
## cache.h ##
@@ cache.h: struct date_mode {
2: 3c7c4f1f55 ! 2: 18ec5b3b3d test_date.c: Remove reference to GIT_TEST_DATE_NOW
@@ Commit message
test_date.c: Remove reference to GIT_TEST_DATE_NOW
Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
- The intialization of variable x with the value from GIT_TEST_DATE_NOW
- is unneeded since x is initalized by skip_prefix().
+ We can't get rid of the "x" variable, since it serves as a generic
+ scratch variable for parsing later in the function.
## t/helper/test-date.c ##
@@ t/helper/test-date.c: static void getnanos(const char **argv)
Stephen P. Smith (2):
Quit passing 'now' to date code
test_date.c: Remove reference to GIT_TEST_DATE_NOW
cache.h | 5 ++---
date.c | 27 +++++++++++++--------------
t/helper/test-date.c | 27 +++++++++------------------
3 files changed, 24 insertions(+), 35 deletions(-)
--
2.23.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/2] Quit passing 'now' to date code
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
@ 2019-09-12 4:11 ` Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
2019-09-13 5:08 ` [PATCH v2 0/2] Date test code clean-up Jeff King
2 siblings, 0 replies; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-12 4:11 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
Commit b841d4ff43 (Add `human` format to test-tool, 2019-01-28) added
a get_time() function which allows $GIT_TEST_DATE_NOW in the
environment to override the current time. So we no longer need to
interpret that variable in cmd__date().
Therefore, we can stop passing the "now" parameter down through the
date functions, since nobody uses them. Note that we do need to make
sure all of the previous callers that took a "now" parameter are
correctly using get_time().
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
---
cache.h | 5 ++---
date.c | 27 +++++++++++++--------------
t/helper/test-date.c | 26 +++++++++-----------------
3 files changed, 24 insertions(+), 34 deletions(-)
diff --git a/cache.h b/cache.h
index b1da1ab08f..48d4287aa7 100644
--- a/cache.h
+++ b/cache.h
@@ -1516,8 +1516,7 @@ struct date_mode {
struct date_mode *date_mode_from_type(enum date_mode_type type);
const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
-void show_date_relative(timestamp_t time, const struct timeval *now,
- struct strbuf *timebuf);
+void show_date_relative(timestamp_t time, struct strbuf *timebuf);
void show_date_human(timestamp_t time, int tz, const struct timeval *now,
struct strbuf *timebuf);
int parse_date(const char *date, struct strbuf *out);
@@ -1526,7 +1525,7 @@ int parse_expiry_date(const char *date, timestamp_t *timestamp);
void datestamp(struct strbuf *out);
#define approxidate(s) approxidate_careful((s), NULL)
timestamp_t approxidate_careful(const char *, int *);
-timestamp_t approxidate_relative(const char *date, const struct timeval *now);
+timestamp_t approxidate_relative(const char *date);
void parse_date_format(const char *format, struct date_mode *mode);
int date_overflows(timestamp_t date);
diff --git a/date.c b/date.c
index 8126146c50..041db7db4e 100644
--- a/date.c
+++ b/date.c
@@ -128,16 +128,17 @@ static void get_time(struct timeval *now)
gettimeofday(now, NULL);
}
-void show_date_relative(timestamp_t time,
- const struct timeval *now,
- struct strbuf *timebuf)
+void show_date_relative(timestamp_t time, struct strbuf *timebuf)
{
+ struct timeval now;
timestamp_t diff;
- if (now->tv_sec < time) {
+
+ get_time(&now);
+ if (now.tv_sec < time) {
strbuf_addstr(timebuf, _("in the future"));
return;
}
- diff = now->tv_sec - time;
+ diff = now.tv_sec - time;
if (diff < 90) {
strbuf_addf(timebuf,
Q_("%"PRItime" second ago", "%"PRItime" seconds ago", diff), diff);
@@ -240,9 +241,7 @@ static void show_date_normal(struct strbuf *buf, timestamp_t time, struct tm *tm
/* Show "today" times as just relative times */
if (hide.wday) {
- struct timeval now;
- get_time(&now);
- show_date_relative(time, &now, buf);
+ show_date_relative(time, buf);
return;
}
@@ -313,11 +312,8 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
}
if (mode->type == DATE_RELATIVE) {
- struct timeval now;
-
strbuf_reset(&timebuf);
- get_time(&now);
- show_date_relative(time, &now, &timebuf);
+ show_date_relative(time, &timebuf);
return timebuf.buf;
}
@@ -1288,15 +1284,18 @@ static timestamp_t approxidate_str(const char *date,
return (timestamp_t)update_tm(&tm, &now, 0);
}
-timestamp_t approxidate_relative(const char *date, const struct timeval *tv)
+timestamp_t approxidate_relative(const char *date)
{
+ struct timeval tv;
timestamp_t timestamp;
int offset;
int errors = 0;
if (!parse_date_basic(date, ×tamp, &offset))
return timestamp;
- return approxidate_str(date, tv, &errors);
+
+ get_time(&tv);
+ return approxidate_str(date, (const struct timeval *) &tv, &errors);
}
timestamp_t approxidate_careful(const char *date, int *error_ret)
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 585347ea48..deb5869343 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -12,13 +12,13 @@ static const char *usage_msg = "\n"
" test-tool date is64bit\n"
" test-tool date time_t-is64bit\n";
-static void show_relative_dates(const char **argv, struct timeval *now)
+static void show_relative_dates(const char **argv)
{
struct strbuf buf = STRBUF_INIT;
for (; *argv; argv++) {
time_t t = atoi(*argv);
- show_date_relative(t, now, &buf);
+ show_date_relative(t, &buf);
printf("%s -> %s\n", *argv, buf.buf);
}
strbuf_release(&buf);
@@ -74,20 +74,20 @@ static void parse_dates(const char **argv)
strbuf_release(&result);
}
-static void parse_approxidate(const char **argv, struct timeval *now)
+static void parse_approxidate(const char **argv)
{
for (; *argv; argv++) {
timestamp_t t;
- t = approxidate_relative(*argv, now);
+ t = approxidate_relative(*argv);
printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601)));
}
}
-static void parse_approx_timestamp(const char **argv, struct timeval *now)
+static void parse_approx_timestamp(const char **argv)
{
for (; *argv; argv++) {
timestamp_t t;
- t = approxidate_relative(*argv, now);
+ t = approxidate_relative(*argv);
printf("%s -> %"PRItime"\n", *argv, t);
}
}
@@ -103,22 +103,14 @@ static void getnanos(const char **argv)
int cmd__date(int argc, const char **argv)
{
- struct timeval now;
const char *x;
-
x = getenv("GIT_TEST_DATE_NOW");
- if (x) {
- now.tv_sec = atoi(x);
- now.tv_usec = 0;
- }
- else
- gettimeofday(&now, NULL);
argv++;
if (!*argv)
usage(usage_msg);
if (!strcmp(*argv, "relative"))
- show_relative_dates(argv+1, &now);
+ show_relative_dates(argv+1);
else if (!strcmp(*argv, "human"))
show_human_dates(argv+1);
else if (skip_prefix(*argv, "show:", &x))
@@ -126,9 +118,9 @@ int cmd__date(int argc, const char **argv)
else if (!strcmp(*argv, "parse"))
parse_dates(argv+1);
else if (!strcmp(*argv, "approxidate"))
- parse_approxidate(argv+1, &now);
+ parse_approxidate(argv+1);
else if (!strcmp(*argv, "timestamp"))
- parse_approx_timestamp(argv+1, &now);
+ parse_approx_timestamp(argv+1);
else if (!strcmp(*argv, "getnanos"))
getnanos(argv+1);
else if (!strcmp(*argv, "is64bit"))
--
2.23.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 1/2] Quit passing 'now' to date code Stephen P. Smith
@ 2019-09-12 4:11 ` Stephen P. Smith
2019-09-13 5:08 ` [PATCH v2 0/2] Date test code clean-up Jeff King
2 siblings, 0 replies; 12+ messages in thread
From: Stephen P. Smith @ 2019-09-12 4:11 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
Remove the reference to the GIT_TEST_DATE_NOW which is done in date.c.
We can't get rid of the "x" variable, since it serves as a generic
scratch variable for parsing later in the function.
Signed-off-by: Stephen P. Smith <ischis2@cox.net>
---
t/helper/test-date.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index deb5869343..099eff4f0f 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -104,7 +104,6 @@ static void getnanos(const char **argv)
int cmd__date(int argc, const char **argv)
{
const char *x;
- x = getenv("GIT_TEST_DATE_NOW");
argv++;
if (!*argv)
--
2.23.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/2] Date test code clean-up
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 1/2] Quit passing 'now' to date code Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
@ 2019-09-13 5:08 ` Jeff King
2019-09-13 17:25 ` Junio C Hamano
2 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2019-09-13 5:08 UTC (permalink / raw)
To: Stephen P. Smith; +Cc: git, Junio C Hamano
On Wed, Sep 11, 2019 at 09:11:00PM -0700, Stephen P. Smith wrote:
> Range Diff:
> 1: f4170ad553 ! 1: e2b8322d58 Quit passing 'now' to date code
> [...]
Thanks, this version addresses all of my concerns from v1 (and overall
looks good).
-Peff
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/2] Date test code clean-up
2019-09-13 5:08 ` [PATCH v2 0/2] Date test code clean-up Jeff King
@ 2019-09-13 17:25 ` Junio C Hamano
0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2019-09-13 17:25 UTC (permalink / raw)
To: Jeff King; +Cc: Stephen P. Smith, git
Jeff King <peff@peff.net> writes:
> On Wed, Sep 11, 2019 at 09:11:00PM -0700, Stephen P. Smith wrote:
>
>> Range Diff:
>> 1: f4170ad553 ! 1: e2b8322d58 Quit passing 'now' to date code
>> [...]
>
> Thanks, this version addresses all of my concerns from v1 (and overall
> looks good).
Yup, the result of applying these look good.
Thanks, both.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-09-13 17:25 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 1:47 [PATCH 0/2] Date test code clean-up Stephen P. Smith
2019-09-09 1:47 ` [PATCH 1/2] Quit passing 'now' to date code Stephen P. Smith
2019-09-09 17:28 ` Jeff King
2019-09-09 1:47 ` [PATCH 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
2019-09-09 17:29 ` Jeff King
2019-09-09 19:44 ` Junio C Hamano
2019-09-09 18:32 ` [PATCH 0/2] Date test code clean-up Junio C Hamano
2019-09-12 4:11 ` [PATCH v2 " Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 1/2] Quit passing 'now' to date code Stephen P. Smith
2019-09-12 4:11 ` [PATCH v2 2/2] test_date.c: Remove reference to GIT_TEST_DATE_NOW Stephen P. Smith
2019-09-13 5:08 ` [PATCH v2 0/2] Date test code clean-up Jeff King
2019-09-13 17:25 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).