# Re: checking out by date

3 messages from 2009-01-12 to 2009-01-12. Participants: Robin Rosenberg, David Bryson, Boyd Stephen Smith Jr..
Thread: https://gitlist.dev/t/17124

## David Bryson, 2009-01-12 19:30

Subject: checking out by date
Message-ID: <20090112193039.GO25823@eratosthenes.cryptobackpack.org>
URL: https://gitlist.dev/e/20090112193039.GO25823%40eratosthenes.cryptobackpack.org

```
Hi All,

I have a very large repository that imported into git from CVS with
about 5 years worth of history.

Today I decided to checkout some code from the past:

$ git checkout master@{"Mon Dec 31  2007"}
warning: Log for 'master' only goes back to Tue, 2 Dec 2008 16:57:15
-0800.

Then proceeds to checkout a code snapshot from 2 Dec.  To work around
this I checked out a specific commit id, by looking at the log:

commit 3771ec1d6ccf329da378b7633fdef60474eac4b7
Author: XXXXXXXXXXXXXXX
Date:   Mon Dec 31 23:25:17 2007 +0000

    BugId: none
    correct wrong commit


$ git checkout 3771ec1d6ccf329da378b7633fdef60474eac4b7
...
HEAD is now at 3771ec1... BugId: none correct wrong commit

So what has caused git to be unable to process the date information,
even though the information is clearly in the history ?  Did I miss
something ?

Dave

```

## Boyd Stephen Smith Jr., 2009-01-12 19:58

Subject: Re: checking out by date
Message-ID: <200901121358.21342.bss@iguanasuicide.net>
URL: https://gitlist.dev/e/200901121358.21342.bss%40iguanasuicide.net
In-Reply-To: <20090112193039.GO25823@eratosthenes.cryptobackpack.org>

```
On Monday 2009 January 12 13:30:39 David Bryson wrote:
>I have a very large repository that imported into git from CVS with
>about 5 years worth of history.
>
>Today I decided to checkout some code from the past:
>
>$ git checkout master@{"Mon Dec 31  2007"}
>warning: Log for 'master' only goes back to Tue, 2 Dec 2008 16:57:15
>-0800.
>
>Then proceeds to checkout a code snapshot from 2 Dec.  To work around
>this I checked out a specific commit id, by looking at the log:
>
>commit 3771ec1d6ccf329da378b7633fdef60474eac4b7
>Author: XXXXXXXXXXXXXXX
>Date:   Mon Dec 31 23:25:17 2007 +0000
>
>$ git checkout 3771ec1d6ccf329da378b7633fdef60474eac4b7
>...
>HEAD is now at 3771ec1... BugId: none correct wrong commit
>
>So what has caused git to be unable to process the date information,
>even though the information is clearly in the history ?  Did I miss
>something ?

The ref@{date} format uses the reflogs which are expired regularly, IIRC.  
Also, I don't think reflogs are built by cvsimport, so they would only go 
back to the import date.

While there is date information in the output of 'git log', some of those 
commits may never have been pointed to by the named ref, so they wouldn't 
satisfy the semantics of "$ref as it was on $date".  With a linear history, 
this "only" puts you in the middle of a fast-forward, which isn't *that* bad.

However, with a non-linear history, taking the ancestor with the latest commit 
date before the given date might end up checking out a topic branch that 
hadn't yet been merged on that date, which could be incredibly confusing.

It should be possible to introduce a commit "spelling" to enable 
checkout-by-date, but I don't know of one currently.  Something 
like "commitish~{date}" meaning "commitish~n where n is the largest value 
s.t. commit_date(commitish~n) <= date", intentionally taking the first parent 
on any merge to discard the merge event.

If this is a feature we feel is valuable, I don't think it would be that hard 
to code.
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

```

## Robin Rosenberg, 2009-01-12 21:24

Subject: Re: checking out by date
Message-ID: <200901122224.37058.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200901122224.37058.robin.rosenberg.lists%40dewire.com
In-Reply-To: <20090112193039.GO25823@eratosthenes.cryptobackpack.org>

```
David Bryson <david@statichacks.org> writes:
> Hi All,
> 
> I have a very large repository that imported into git from CVS with
> about 5 years worth of history.
> 
> Today I decided to checkout some code from the past:
> 
> $ git checkout master@{"Mon Dec 31  2007"}
> warning: Log for 'master' only goes back to Tue, 2 Dec 2008 16:57:15
> -0800.

git checkout $(git rev-list -n1 --before="Mon Dec 31  2007 23:59:59")

-- robin

```
