* Is there way to set git commit --date to be older than 1970 ?
@ 2014-10-29 18:49 Peter Vojtek
2014-10-29 19:19 ` Fredrik Gustafsson
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Peter Vojtek @ 2014-10-29 18:49 UTC (permalink / raw)
To: git
Hello all,
I am playing with git in slightly unusual manner - e.g., to use git to
store history of europe:
$ touch Italy
$ git add Italy
$ git commit -m "add Italy" --date="01/01/1861T01:01:01" # Italy
gained sovereignity at year 1861
fatal: invalid date format: 01/01/1861T01:01:01
It seems the commit date can be between 1970 and 2100 (on my 32bit
linux), however man git (section DATE FORMATS) claims ISO 8601
standard is supported. ISO 8601 allows even B.C. dates (via minus
sign).
I understand that this is rather an esoteric use case :)
Regards,
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 18:49 Is there way to set git commit --date to be older than 1970 ? Peter Vojtek
@ 2014-10-29 19:19 ` Fredrik Gustafsson
2014-10-29 19:50 ` Peter Vojtek
2014-10-29 19:31 ` Junio C Hamano
2014-10-30 17:24 ` Junio C Hamano
2 siblings, 1 reply; 9+ messages in thread
From: Fredrik Gustafsson @ 2014-10-29 19:19 UTC (permalink / raw)
To: Peter Vojtek; +Cc: git
On Wed, Oct 29, 2014 at 07:49:19PM +0100, Peter Vojtek wrote:
> I am playing with git in slightly unusual manner - e.g., to use git to
> store history of europe:
Actually you're the second person I hear that is trying to use git as a
timeline of some sort. The previous person had the exact same problem.
Unfortunately I couldn't find a mailthread about it in the archives.
I'm curious, why did you choose git for this? Maybe this is a use case
we should consider?
--
Med vänlig hälsning
Fredrik Gustafsson
tel: 0733-608274
e-post: iveqy@iveqy.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 19:19 ` Fredrik Gustafsson
@ 2014-10-29 19:50 ` Peter Vojtek
0 siblings, 0 replies; 9+ messages in thread
From: Peter Vojtek @ 2014-10-29 19:50 UTC (permalink / raw)
To: Fredrik Gustafsson; +Cc: git
thanks for quick response, Fredrik.
> I'm curious, why did you choose git for this? Maybe this is a use case
we should consider?
this is a part of "thinking out of the box" mental execise.
With the advent of many tools to visualize and analyze git
repositories, it makes some sense to use the underlying beauty and
power of git for unusual use cases. Similar evolution happened to
javascript (originally a simple language to apply form validations on
browser side).
Here are few other use cases which may be fun to realize with git:
- history of political parties in one country. when a party splits
into two, we create new branch, and when parties join, we merge
branches. branch name = party name. commiter name = party leader.
- how country populations evolve year by year. country is a file,
bytesize equals to its population.
- track evolution of some political document (e.g., u.s. constitution).
Peter
On Wed, Oct 29, 2014 at 8:19 PM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> On Wed, Oct 29, 2014 at 07:49:19PM +0100, Peter Vojtek wrote:
>> I am playing with git in slightly unusual manner - e.g., to use git to
>> store history of europe:
>
> Actually you're the second person I hear that is trying to use git as a
> timeline of some sort. The previous person had the exact same problem.
> Unfortunately I couldn't find a mailthread about it in the archives.
>
> I'm curious, why did you choose git for this? Maybe this is a use case
> we should consider?
>
> --
> Med vänlig hälsning
> Fredrik Gustafsson
>
> tel: 0733-608274
> e-post: iveqy@iveqy.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 18:49 Is there way to set git commit --date to be older than 1970 ? Peter Vojtek
2014-10-29 19:19 ` Fredrik Gustafsson
@ 2014-10-29 19:31 ` Junio C Hamano
2014-10-29 20:03 ` Roberto Eduardo Decurnex Gorosito
2014-10-30 21:08 ` Dan Johnson
2014-10-30 17:24 ` Junio C Hamano
2 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2014-10-29 19:31 UTC (permalink / raw)
To: Peter Vojtek; +Cc: git
Peter Vojtek <peter.vojtek@gmail.com> writes:
> It seems the commit date can be between 1970 and 2100 (on my 32bit
> linux),...
The underlying data representation records time as number of seconds
since epoch (1970-01-01). Theoretically the codepaths that read
data could consider negative timestamps to represent times before
the epoch, but in the context of source code control, negative
values are more likely to be an indication of a bug or a user
mistake, and I do not think any existing code in Git is prepared to
pass such a timestamp as a sane value---instead they diagnose a
failure and die.
> I understand that this is rather an esoteric use case :)
Yeah, this is pretty much outside of what we intend to support.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 19:31 ` Junio C Hamano
@ 2014-10-29 20:03 ` Roberto Eduardo Decurnex Gorosito
2014-10-30 21:08 ` Dan Johnson
1 sibling, 0 replies; 9+ messages in thread
From: Roberto Eduardo Decurnex Gorosito @ 2014-10-29 20:03 UTC (permalink / raw)
To: Peter Vojtek; +Cc: git
Peter,
You should be happy of getting the error message.
Since Git 2 invalid years will default to the current year (keeping
the given day and month) without warnings.
--
Roberto Decurnex
On Wed, Oct 29, 2014 at 4:31 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Peter Vojtek <peter.vojtek@gmail.com> writes:
>
>> It seems the commit date can be between 1970 and 2100 (on my 32bit
>> linux),...
>
> The underlying data representation records time as number of seconds
> since epoch (1970-01-01). Theoretically the codepaths that read
> data could consider negative timestamps to represent times before
> the epoch, but in the context of source code control, negative
> values are more likely to be an indication of a bug or a user
> mistake, and I do not think any existing code in Git is prepared to
> pass such a timestamp as a sane value---instead they diagnose a
> failure and die.
>
>> I understand that this is rather an esoteric use case :)
>
> Yeah, this is pretty much outside of what we intend to support.
>
> Thanks.
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 19:31 ` Junio C Hamano
2014-10-29 20:03 ` Roberto Eduardo Decurnex Gorosito
@ 2014-10-30 21:08 ` Dan Johnson
2014-10-30 21:48 ` Jeff King
1 sibling, 1 reply; 9+ messages in thread
From: Dan Johnson @ 2014-10-30 21:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Peter Vojtek, Git Mailing List
On Wed, Oct 29, 2014 at 3:31 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Peter Vojtek <peter.vojtek@gmail.com> writes:
>
>> It seems the commit date can be between 1970 and 2100 (on my 32bit
>> linux),...
>
> The underlying data representation records time as number of seconds
> since epoch (1970-01-01). Theoretically the codepaths that read
> data could consider negative timestamps to represent times before
> the epoch, but in the context of source code control, negative
> values are more likely to be an indication of a bug or a user
> mistake, and I do not think any existing code in Git is prepared to
> pass such a timestamp as a sane value---instead they diagnose a
> failure and die.
I remember a pretty old thread found some success storing timestamps this way:
http://comments.gmane.org/gmane.comp.version-control.git/152433
-Dan Johnson
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-30 21:08 ` Dan Johnson
@ 2014-10-30 21:48 ` Jeff King
2014-10-30 22:11 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Jeff King @ 2014-10-30 21:48 UTC (permalink / raw)
To: Dan Johnson; +Cc: Junio C Hamano, Peter Vojtek, Git Mailing List
On Thu, Oct 30, 2014 at 05:08:56PM -0400, Dan Johnson wrote:
> > The underlying data representation records time as number of seconds
> > since epoch (1970-01-01). Theoretically the codepaths that read
> > data could consider negative timestamps to represent times before
> > the epoch, but in the context of source code control, negative
> > values are more likely to be an indication of a bug or a user
> > mistake, and I do not think any existing code in Git is prepared to
> > pass such a timestamp as a sane value---instead they diagnose a
> > failure and die.
>
> I remember a pretty old thread found some success storing timestamps this way:
> http://comments.gmane.org/gmane.comp.version-control.git/152433
A few things have changed since then. Most notably, git is more careful
about overflow of "unsigned long" when reading in timestamp values. Of
course, we can't do much in the overflow case except assign a sentinel
value. But it at least means that overflowing values all end up as "Jan
1 1970" and not whatever random 32-bit wraparound you happen to get.
But what _hasn't_ changed is that we still use "unsigned long"
internally. The fact that the 1787 date in that thread worked at all is
somewhat accidental and due to implicit casts between "unsigned long"
and "time_t" working. As noted here (and downthread):
http://permalink.gmane.org/gmane.comp.version-control.git/152508
I think it would be a nice project to convert git to consistently use
signed 64-bit times internally, and then everything would Just Work
going back to the beginning of history. But the demand for such a
feature has been low enough that nobody has really dug in and tried the
conversion.
We do also gain some small amount of efficiency by storing commit
timestamps as 32-bit values. However, those should always be "current"
times anyway. I think we are really talking about author timestamps
here (and of course the underlying time-manipulation functions).
-Peff
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-30 21:48 ` Jeff King
@ 2014-10-30 22:11 ` Junio C Hamano
0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2014-10-30 22:11 UTC (permalink / raw)
To: Jeff King; +Cc: Dan Johnson, Peter Vojtek, Git Mailing List
Jeff King <peff@peff.net> writes:
> I think it would be a nice project to convert git to consistently use
> signed 64-bit times internally, and then everything would Just Work
> going back to the beginning of history. But the demand for such a
> feature has been low enough that nobody has really dug in and tried the
> conversion.
>
> We do also gain some small amount of efficiency by storing commit
> timestamps as 32-bit values. However, those should always be "current"
> times anyway. I think we are really talking about author timestamps
> here (and of course the underlying time-manipulation functions).
There are only three places we store timestamps that matter in the
on-disk representations, so if we were to go 64-bit internally,
which I do not mind at all, we probably should do all three i.e.,
committer, tagger and author dates.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Is there way to set git commit --date to be older than 1970 ?
2014-10-29 18:49 Is there way to set git commit --date to be older than 1970 ? Peter Vojtek
2014-10-29 19:19 ` Fredrik Gustafsson
2014-10-29 19:31 ` Junio C Hamano
@ 2014-10-30 17:24 ` Junio C Hamano
2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2014-10-30 17:24 UTC (permalink / raw)
To: Peter Vojtek; +Cc: git
Peter Vojtek <peter.vojtek@gmail.com> writes:
> It seems the commit date can be between 1970 and 2100 (on my 32bit
> linux), however man git (section DATE FORMATS) claims ISO 8601
> standard is supported.
The date formats section of "git log" only talks about the output
format (I do not see in "man git" any section about date formats, by
the way), once Git understands and records the timestamp in its
internal representation (which is "seconds since the epoch"; as I
already said, theoretically it should be possible to record negative
number of seconds there, the current code does not allow it).
The documentation may need to be clarified, independent from what
the implementation does on the input side. The current text from
"git log" reads like so:
--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
Only takes effect for dates shown in human-readable
format, such as when using --pretty. log.date config
variable sets a default value for the log command’s
--date option.
The word "shown" is meant to stress that this description is about
output side, but apparently it was misread as if somehow a user can
affect the input by giving --date=iso or something, so perhaps you
would want to suggest a better phrasing?
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-10-30 22:12 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-29 18:49 Is there way to set git commit --date to be older than 1970 ? Peter Vojtek
2014-10-29 19:19 ` Fredrik Gustafsson
2014-10-29 19:50 ` Peter Vojtek
2014-10-29 19:31 ` Junio C Hamano
2014-10-29 20:03 ` Roberto Eduardo Decurnex Gorosito
2014-10-30 21:08 ` Dan Johnson
2014-10-30 21:48 ` Jeff King
2014-10-30 22:11 ` Junio C Hamano
2014-10-30 17:24 ` Junio C Hamano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.