Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
parse_date_basic(): return early when given a bogus timestamp
author
Junio C Hamano
<gitster@pobox.com>
Wed, 15 Apr 2015 15:43:58 +0000
(08:43 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 15 Apr 2015 17:25:05 +0000
(10:25 -0700)
When the input does not have GMT timezone offset, the code computes
it by computing the local and GMT time for the given timestamp. But
there is no point doing so if the given timestamp is known to be a
bogus one.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
date.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
282616c
)
diff --git
a/date.c
b/date.c
index 782de95d90c6ac1a02ddfa0df81ca93ecdf910c4..76fb47518dfb1eb982e0497b6e261aa0e91fe67d 100644
(file)
--- a/
date.c
+++ b/
date.c
@@
-696,6
+696,9
@@
int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
/* mktime uses local timezone */
*timestamp = tm_to_time_t(&tm);
/* mktime uses local timezone */
*timestamp = tm_to_time_t(&tm);
+ if (*timestamp == -1)
+ return -1;
+
if (*offset == -1) {
time_t temp_time = mktime(&tm);
if ((time_t)*timestamp > temp_time) {
if (*offset == -1) {
time_t temp_time = mktime(&tm);
if ((time_t)*timestamp > temp_time) {
@@
-705,9
+708,6
@@
int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
}
}
}
}
- if (*timestamp == -1)
- return -1;
-
if (!tm_gmt)
*timestamp -= *offset * 60;
return 0; /* success */
if (!tm_gmt)
*timestamp -= *offset * 60;
return 0; /* success */