From: Mike Gorchak <mike.gorchak.qnx@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 1/1] Fix date checking in case if time was not initialized.
Date: Mon, 25 Feb 2013 10:36:29 +0200 [thread overview]
Message-ID: <CAHXAxrOOqn6ZSVT1AFyO3a3paD1tokBtcnaX68a+ddhodOvZ6Q@mail.gmail.com> (raw)
Fix is_date() function failings in detection of correct date in case
if time was not properly initialized.
From: Mike Gorchak <mike.gorchak.qnx@gmail.com>
Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
---
date.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/date.c b/date.c
index 57331ed..ec758f4 100644
--- a/date.c
+++ b/date.c
@@ -357,6 +357,7 @@ static int is_date(int year, int month, int day,
struct tm *now_tm, time_t now,
if (month > 0 && month < 13 && day > 0 && day < 32) {
struct tm check = *tm;
struct tm *r = (now_tm ? &check : tm);
+ struct tm fixed_r;
time_t specified;
r->tm_mon = month - 1;
@@ -377,7 +378,16 @@ static int is_date(int year, int month, int day,
struct tm *now_tm, time_t now,
if (!now_tm)
return 1;
- specified = tm_to_time_t(r);
+ /* Fix tm structure in case if time was not initialized */
+ fixed_r = *r;
+ if (fixed_r.tm_hour==-1)
+ fixed_r.tm_hour=0;
+ if (fixed_r.tm_min==-1)
+ fixed_r.tm_min=0;
+ if (fixed_r.tm_sec==-1)
+ fixed_r.tm_sec=0;
+
+ specified = tm_to_time_t(&fixed_r);
/* Be it commit time or author time, it does not make
* sense to specify timestamp way into the future. Make
--
1.8.2-rc0
next reply other threads:[~2013-02-25 8:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 8:36 Mike Gorchak [this message]
2013-02-25 18:26 ` [PATCH 1/1] Fix date checking in case if time was not initialized Junio C Hamano
2013-02-25 18:43 ` Mike Gorchak
2013-02-25 19:04 ` Junio C Hamano
2013-02-25 19:32 ` Mike Gorchak
2013-02-25 19:37 ` Junio C Hamano
2013-02-25 21:47 ` Mike Gorchak
2013-02-25 22:07 ` Junio C Hamano
2013-02-26 18:58 ` Mike Gorchak
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=CAHXAxrOOqn6ZSVT1AFyO3a3paD1tokBtcnaX68a+ddhodOvZ6Q@mail.gmail.com \
--to=mike.gorchak.qnx@gmail.com \
--cc=git@vger.kernel.org \
/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).