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

Question about timezones in commit & tag dates

From
Fabian Stelzer <fs@gigacodes.de>
Date
Sep 12, 2021, 11:35 UTC
Message-ID
<b39aab0a-bf53-9e33-59a7-d4f1a06e72a7@gigacodes.de>

Hi, while working on correct key rollover and verifying signatures for past commits for the ssh signing topic i am trying to understand how Git deals with timestamps for commits & tags. For ssh signing the user will manage expiration times within their allowedSigners file. Those timestamps do not carry a timezone and i would assume a user (or automatic generation of this file) will assume the systems timezone for them. Therefore i wanted to pass the commit & tags timestamps adjusted to the system timezone to make sure key rollover will have no gaps or failed verification's especially when commit and system timezone differ greatly and might roll over to another day.

However the commit & tags structs only seem to carry the objects timestamp as is, simply ignoring any timezone information. For the ssh feature i can easily enough parse the ident line again from the object header. But while looking at the usage of the existing date fields i can see that objects are sometimes sorted on and compared by these dates. When commands provide cut off times (--since) i think they might include or exclude commits erroneously when they were made in a different timezone around the cutoff date. ("log --since" indeed gives me some unexpected results when mixing multiple timezones. Based on some simple testing i think it just stops output when a commit falls outside of this window, even though there might be one before it wich is within)

Is my understanding of this correct and this the expected behaviour? I think generally for git this does not matter much. But in certain situations this is problematic.

I would have assumed that git would either add the timezone as well or adjust the commit timestamp upon populating the date field in the commit struct to UTC but i could not find anything like it.

Best regards, Fabian

Next: Ævar Arnfjörð Bjarmason
Message 1 of 4 in “Question about timezones in commit & tag dates”
  1. Fabian StelzerSep 12, 2021
  2. Ævar Arnfjörð BjarmasonSep 12, 2021
  3. Fabian StelzerSep 12, 2021
  4. Philip OakleySep 12, 2021

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.