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

Re: Back-dating commits--way back--for constitution.git

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Aug 3, 2010, 08:55 UTC
Message-ID
<4C57D997.5010003@drmicha.warpmail.net>
In-Reply-To
<m3hbjcptyr.fsf@localhost.localdomain>
Jakub Narebski venit, vidit, dixit 02.08.2010 23:48:
Show 30 quoted lines
> "Joel C. Salomon" <joelcsalomon@gmail.com> writes:
> 
>> I'd figured to play with Git in an unusual way: to create a repository
>> for the U.S. Constitution where amendments are presented as patches.
>> E.g., instead of the First Amendment being placed at the end (as is
>> usual) I'm putting it in Article 1, Section 9 (Limitations of Congress).
>>  Proposed amendments get branches, which get merged in later.
>>
>> But I'm trying to get the dates right, and I'm missing something.  For
>> example, I made the initial commit with the line
>>
>> 	$ git commit --author="The Philadelphia Convention <>" \
>> 	 --date="Mon, 17 Sep 1787 12:00:00 EST"
>>
>> but that's not actually setting the commit date to 1787.
>>
>> Am I doing something wrong, or is Git (quite reasonably) unable to
>> accept commit dates that far in the past?
> 
> Git encodes author and commit (and tagger) time using Unix epoch
> (POSIX epoch) plus timezone.  As Shawn and Ævar wrote on 32-bit
> systems time_t can cover a range of about 136 years in total around
> January 1, 1970, which means that the maximum representable time on
> 32-bit system is 2038-01-19 (the year 2038 problem), but what is more
> important to you is that minimum representable time is 1901-12-13.
> 1787 is too old for 32-bit time_t.
> 
> The headers inside commit (and tag) objects are stored in text form,
> so they are not limited to 32-bit value.  You would have to use system
> that has 64-bit time_t, or patch git.

Hmm, sizeof(time_t) == 8 for my x86_64 Fedora, but committing ancient times fails.

My ctime() happily converts negative numbers into dates before the epoch.
Show 6 quoted lines
> 
> 64-bit time_t would be enough for everyone (sic!).
> 
> References:
> -----------
> http://en.wikipedia.org/wiki/Unix_epoch
Junio replied:
>I thought the internal representation of our time was "unsigned long", >no?
>How can you represent anything before Unix epoch?

We have a mix of time_t and unsigned long (not signed, not long long!), and we have our own tm_to_time_t() in date.c which explicitly forbids years before 1970. It seems we don't use standard ctime() and friends because the standards is not so standard and want to be independent of that, but sizeof(long) is still system dependent.

Removing the check in tm_to_time_t() by brute force let's me commit ancient times, but the parser gets them wrong (either on input or on output, I haven't checked), 1787 ends up output as 1899.

time_t is signed on most systems. Using unsigned long buys us a few years as long as we don't go through any system routine nor conversion to time_t. So maybe we should:

- check to make sure we use time_t and system routines only when getting
the current time
- use signed long long as our git_time_t (I think long is less system
dependent then long but I could be wrong)
- make our own algorithms work for the extended format
Michael
Previous: Jakub NarebskiNext: Joshua Juran
Message 25 of 36 in “Back-dating commits--way back--for constitution.git”
  1. Joel C. SalomonAug 2, 2010
  2. Shawn O. PearceAug 2, 2010
  3. Joel C. SalomonAug 2, 2010
  4. Ævar Arnfjörð BjarmasonAug 2, 2010
  5. Joel C. SalomonAug 4, 2010
  6. Ævar Arnfjörð BjarmasonAug 4, 2010
  7. Joel C. SalomonAug 5, 2010
  8. Ævar Arnfjörð BjarmasonAug 5, 2010
  9. Sverre RabbelierAug 5, 2010
  10. Jakub NarebskiAug 6, 2010
  11. Michael WittenAug 6, 2010
  12. Sverre RabbelierAug 6, 2010
  13. Joel C. SalomonAug 6, 2010
  14. Ævar Arnfjörð BjarmasonAug 6, 2010
  15. Joel C. SalomonAug 6, 2010
  16. Brandon CaseyAug 6, 2010
  17. Ævar Arnfjörð BjarmasonAug 6, 2010
  18. Brandon CaseyAug 6, 2010
  19. Joel C. SalomonAug 8, 2010
  20. Joshua JuranAug 8, 2010
  21. Jakub NarebskiAug 2, 2010
  22. Junio C HamanoAug 2, 2010
  23. Jakub NarebskiAug 3, 2010
  24. Jakub NarebskiAug 3, 2010
  25. Michael J GruberAug 3, 2010
  26. Joshua JuranAug 3, 2010
  27. Jeff KingAug 3, 2010
  28. Joshua JuranAug 3, 2010
  29. Jeff KingAug 3, 2010
  30. Jakub NarebskiAug 3, 2010
  31. Jakub NarebskiAug 3, 2010
  32. Jeff KingAug 3, 2010
  33. Jakub NarebskiAug 3, 2010
  34. Jeff KingAug 3, 2010
  35. Michael J GruberAug 3, 2010
  36. Jeff KingAug 3, 2010

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.