Re: MinGW port - initial work uploaded
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Jan 22, 2007, 16:39 UTC
- Message-ID
- <Pine.LNX.4.64.0701220823260.32200@woody.linux-foundation.org>
- In-Reply-To
- <46d6db660701220506t20214d3bi4d0e1e93abd01aad@mail.gmail.com>
On Mon, 22 Jan 2007, Christian MICHON wrote:
> > One problem I haven't found a solution for though: the date > of commit is wrong, always back to epoch (1970???).
Without knowing MinGW, I'd assume it's one of two issues:
- parse_date will probably do this when the date is empty. The way git works, is it takes the date from the GIT_COMMITTER|AUTHOR_DATE environment variables, and it depends on getenv() returning NULL if that environment variable isn't set.
Maybe getenv() under MinGW always returns a real string, and it's just empty? If so, get_ident() should probably be changed from doing
if (date_str) parse_date(...)
to
if (date_str && *date_str) parse_date(...)
or something like that.
- datestamp() uses "time()" to get the number of seconds since the epoch. HOWEVER, it does it by actually doing
time_t now;
time(&now);
which is proper, but maybe a bit unusual. Try changing that to
now = time(NULL);
and see if that changes behaviour (it's datestamp() in date.c).
Alternatively, if "time()" just doesn't work in MinGW, just use gettimeofday() instead, something like
time_t now; int offset; struct timeval tv; struct timezone tz;
/* Just in case not everybody necessarily fills in TZ correctly.. */ memset(&tz, 0, sizeof(tz)); gettimeofday(&tv, &tz); now = tv.tv_sec; offset = tz.tz_minuteswest;
instead of the current mess with localtime() and company.
[ NOTE NOTE NOTE! The above gettimeofday() thing has NOT been tested.
Using the "tz" value to gettimeofday() is generally considered a bug,
and shouldn't really be done. It's very traditional (read:
old-fashioned) and very incorrect (it will ignore the TZ variable,
and ask the kernel, which generally has no clue at all about
timezones). But maybe it works on MinGW, so it might be worth
testing. ]Anyway. I have no idea of Windows or MinGW, or what you did to make it all compile, so..
Linus