parse_date_basic(): return early when given a bogus timestamp

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>

Junio C Hamano committed Apr 15, 2015 at 08:43 UTC 7fcec48da90f95dc64268ebd4b3073ae9487fe4e
1 file changed +3 -3
date.c
+3 -3
@@ -696,6 +696,9 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
696
697 /* mktime uses local timezone */
698 *timestamp = tm_to_time_t(&tm);
699 + if (*timestamp == -1)
700 + return -1;
701 +
702 if (*offset == -1) {
703 time_t temp_time = mktime(&tm);
704 if ((time_t)*timestamp > temp_time) {
@@ -705,9 +708,6 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
708 }
709 }
710
708 - if (*timestamp == -1)
709 - return -1;
710 -
711 if (!tm_gmt)
712 *timestamp -= *offset * 60;
713 return 0; /* success */