summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-08-31 02:31:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-08-31 05:04:56 (GMT)
commit931e8e27d94dbc24abc9c969ae0b414e0361abff (patch)
treecd72a65adcd41a0805b74d1886ee9bae7bf2841d /date.c
parent34dc6e73b01011fcbe0f314d47fd6120382ae145 (diff)
downloadgit-931e8e27d94dbc24abc9c969ae0b414e0361abff.zip
git-931e8e27d94dbc24abc9c969ae0b414e0361abff.tar.gz
git-931e8e27d94dbc24abc9c969ae0b414e0361abff.tar.bz2
fix approxidate parsing of relative months and years
These were broken by b5373e9. The problem is that the code marks the month and year with "-1" for "we don't know it yet", but the month and year code paths were not adjusted to fill in the current time before doing their calculations (whereas other units follow a different code path and are fine). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'date.c')
-rw-r--r--date.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/date.c b/date.c
index 8e57e5e..e9ee4aa 100644
--- a/date.c
+++ b/date.c
@@ -857,7 +857,9 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
}
if (match_string(date, "months") >= 5) {
- int n = tm->tm_mon - *num;
+ int n;
+ update_tm(tm, now, 0); /* fill in date fields if needed */
+ n = tm->tm_mon - *num;
*num = 0;
while (n < 0) {
n += 12;
@@ -868,6 +870,7 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm
}
if (match_string(date, "years") >= 4) {
+ update_tm(tm, now, 0); /* fill in date fields if needed */
tm->tm_year -= *num;
*num = 0;
return end;