Re: [Bug] git-log prints wrong unixtime with --date=format:%s

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 18, 2016 at 09:21:34AM -0700, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> writes:
> 
> > I tried a few obvious things, but couldn't make anything work. Setting
> > "timezone" manually seems to do nothing. It's supposed to be set by
> > putting the right thing in $TZ and then calling tzset(). So I tried
> > munging $TZ to something like "+0200". It did have _some_ effect, but I
> 
> Wouldn't that be more like "UTC+0200"?

Maybe. I tried several different things, and couldn't make it work
sensibly with any of them. My test case is basically:

  git log --format="%ad%n%at" --date=format:'%H:%M %z (%Z)%n%s'

Which should give three lines: the human-readable time and date,
strftime's epoch time, and git's epoch time. And the following
conditions should be met:

  1. The human-readable time is in the author's timezone (or the user's
     if you use format-local).

  2. The zone offset and name in the first line matches the time we
     show.

  3. The epoch times for the latter lines should match.

We currently get (1) right (which is good, because it is IMHO the most
important). I haven't been able to get (2) to change at all, no matter
what I do. And (3) is the subject of debate here; I suspect I could make
it work at the cost of breaking (1) by giving a "struct tm" that is in
UTC.

> In any case, I do not think anybody wants to do tzset() on each and
> every commit while running "git log".  Can we declare "format:<strftime>"
> will always use the local timezone, or something?

I think that is basically the case already. It is in the author's
timezone or in the viewing user's timezone (as reported by localtime()),
and everything seems to work except the %z zone information and the %s
format.

For a raw "%s" date-format, my suggestion is: don't. It is redundant
with --date=raw.

I'd love to make %z work, but I have no idea how.

So I guess we could list those in BUGS in one of the manpages.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]