git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG REPORT] Git log pretty date

From
Jeff King <peff@peff.net>
Date
Jun 3, 2014, 06:45 UTC
Message-ID
<20140603064526.GB26150@sigill.intra.peff.net>
In-Reply-To
<20140603062301.GA22149@spirit>
On Tue, Jun 03, 2014 at 08:23:02AM +0200, Dennis Kaarsemaker wrote:
Show 21 quoted lines
> On Mon, Jun 02, 2014 at 11:46:19PM -0400, Jeff King wrote:
> > On Fri, May 30, 2014 at 09:08:57AM +0100, Rodrigo Fernandes wrote:
> > 
> > > Do you have any idea how does github understand that is a bug and
> > > fixes it automatically?
> > > (I'm saying this because on Github the date is correct).
> > 
> > I looked into this. The dates you see on GitHub's web UI are actually
> > parsed by Rugged/libgit2. The libgit2 parser is slightly more forgiving
> > in this instance; if it sees a broken timezone, it will leave the
> > timestamp intact, and only omit the timezone. Whereas git says "no, it's
> > broken, and the timestamp cannot be trusted".
> > 
> > I think both are equally valid strategies, and I do not even think it is
> > a problem that they diverge between the two implementations. I'd be OK
> > with a patch to make git handle errors in each independently, assuming
> > it is not too invasive.
> 
> I think what libgit2 does is more wrong than what git does. It displays
> the timestamp subtly wrong (off by 7 hours) instead of making it
> completely clear that the timestamp is bogus.

I'm not sure what you mean. The timestamp is in UTC seconds-since-epoch, and does not depend on the timezone. The timezone only indicates the author's local time when the commit was made.

Whether the latter is relevant depends on the date format you are showing (i.e., if you are showing it in the author's timezone, it matters; for --date=local or --date=relative, it would not).

So I do not think libgit2 is at fault for parsing them separately; it does not know how the result will be presented. What GitHub shows is wrong, as it tries to put the timestamp into the author's timezone (which it doesn't know). But in practice it turns out be more useful, because we show relative dates for recent things (so "8 hours ago" is actually accurate and does not care about the timestamp). For distant things, time zone effects become less important (we show "Oct 29, 2010"; it may have actually been Oct 30 or Oct 28 in the author's zone, but it's really not that important anymore).

Those comments are just on the two strategies. As far as implementations, it looks like libgit2 somehow parses this commit as +0700, which is odd. I'd expect it to fall back to +0000. I didn't dig further.

-Peff
Previous: Dennis KaarsemakerNext: Dennis Kaarsemaker
Message 10 of 13 in “[BUG REPORT] Git log pretty date”
  1. Rodrigo FernandesMay 29, 2014
  2. Duy NguyenMay 29, 2014
  3. Jeff KingMay 29, 2014
  4. Junio C HamanoMay 29, 2014
  5. Jeff KingMay 29, 2014
  6. Rodrigo FernandesMay 29, 2014
  7. Rodrigo FernandesMay 30, 2014
  8. Jeff KingJun 3, 2014
  9. Dennis KaarsemakerJun 3, 2014
  10. Jeff KingJun 3, 2014
  11. Dennis KaarsemakerMay 29, 2014
  12. Rodrigo FernandesMay 29, 2014
  13. Duy NguyenMay 29, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.