git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* referencing a revision at a certain date
@ 2008-02-11 18:04 David Madore
  2008-02-11 18:29 ` Jeff King
  2008-02-11 18:40 ` Jakub Narebski
  0 siblings, 2 replies; 4+ messages in thread
From: David Madore @ 2008-02-11 18:04 UTC (permalink / raw)
  To: GIT mailing-list

Hi,

I'm left quite confused by the git-rev-parse(1) man page, I wonder if
someone can help me with this.

I understand that if "rev" denotes a certain revision, then "rev~42"
references the commit which is 42 generations back from rev.  What I'd
like to do is write something like "rev~@{2008-01-18}" (say) to get
the same thing but with the 42 being computed automatically so that
the commit in question is the latest possible (in commit date) before
2008-01-18.  Is this possible?  If so, how?  If not, might I suggest
this as an addition for consideration?

I thought "rev@{2008-01-18}" did this, but apparently it doesn't: it
requires a ref log of some kind, and I don't know how to make a ref
log (git-clone doesn't seem to copy them).

So, is there some way I can either generate a ref log by
systematically taking the first parent in each commit as per git-log
--first-parent, OR (better) specify a revision directly that way?

Typical problem I'm faced with:

mizar david /tmp $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Initialized empty Git repository in /tmp/linux-2.6/.git/
remote: Counting objects: 712898, done.
remote: Compressing objects: 100% (124199/124199), done.
Indexing 712898 objects...
remote: Total 712898 (delta 591709), reused 708828 (delta 587713)
 100% (712898/712898) done
Resolving 591709 deltas...
 100% (591709/591709) done
Checking 23757 files out...
 100% (23757/23757) done
mizar david /tmp $ cd linux-2.6
mizar david /tmp/linux-2.6 $ git rev-parse 'master@{2008-02-01}'
warning: Log for 'master' only goes back to Mon, 11 Feb 2008 18:34:33 +0100.
0000000000000000000000000000000000000000
mizar david /tmp/linux-2.6 $ git rev-parse 'origin@{2008-02-01}'
warning: Log for 'origin' only goes back to Mon, 11 Feb 2008 18:34:32 +0100.
0000000000000000000000000000000000000000
mizar david /tmp/linux-2.6 $ git cat-file -p 'master~1126' | head -5
tree a72dadd4a8b4957a4e21bf7ae38a763a71d6e274
parent e1a9c9872dd004617555dff079b357a6ffd945e9
parent c4772d99300a9fc13c86aaa370e630c5973664f6
author Linus Torvalds <torvalds@linux-foundation.org> 1201821909 +1100
committer Linus Torvalds <torvalds@linux-foundation.org> 1201821909 +1100

=> there must be some intelligent way of finding this revision, but
which is it?

Cheers,

-- 
     David A. Madore
    (david.madore@ens.fr,
     http://www.madore.org/~david/ )

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: referencing a revision at a certain date
  2008-02-11 18:04 referencing a revision at a certain date David Madore
@ 2008-02-11 18:29 ` Jeff King
  2008-02-11 18:40 ` Jakub Narebski
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff King @ 2008-02-11 18:29 UTC (permalink / raw)
  To: David Madore; +Cc: GIT mailing-list

On Mon, Feb 11, 2008 at 07:04:24PM +0100, David Madore wrote:

> I understand that if "rev" denotes a certain revision, then "rev~42"
> references the commit which is 42 generations back from rev.  What I'd
> like to do is write something like "rev~@{2008-01-18}" (say) to get
> the same thing but with the 42 being computed automatically so that
> the commit in question is the latest possible (in commit date) before
> 2008-01-18.  Is this possible?  If so, how?  If not, might I suggest
> this as an addition for consideration?

How about --before=2008-01-18? As in,

  git log --before=2008-01-18

to start your log there (and "git log -1 --before=2008-01-18" if you
just want that one commit).

> I thought "rev@{2008-01-18}" did this, but apparently it doesn't: it
> requires a ref log of some kind, and I don't know how to make a ref
> log (git-clone doesn't seem to copy them).

Ref logs are a log of where your particular, local ref was pointing to.
In other words, it is a history not of the project commits, but of an
individual branch in your local repository. So you don't ask the reflog
things like "which commit has a date at X" but rather "where was my
master branch pointing at 3pm yesterday?"

And because they are purely a local matter, they don't get copied by
clone.

> So, is there some way I can either generate a ref log by
> systematically taking the first parent in each commit as per git-log
> --first-parent, OR (better) specify a revision directly that way?

So this question doesn't really make sense. You generate a ref log by
doing operations on a branch.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: referencing a revision at a certain date
  2008-02-11 18:04 referencing a revision at a certain date David Madore
  2008-02-11 18:29 ` Jeff King
@ 2008-02-11 18:40 ` Jakub Narebski
  2008-02-11 18:57   ` David Madore
  1 sibling, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2008-02-11 18:40 UTC (permalink / raw)
  To: David Madore; +Cc: GIT mailing-list

David Madore <david.madore@ens.fr> writes:

> I'm left quite confused by the git-rev-parse(1) man page, I wonder if
> someone can help me with this.
> 
> I understand that if "rev" denotes a certain revision, then "rev~42"
> references the commit which is 42 generations back from rev.  

To be more exact it is 42 generations in straight, first-parent
line. rev~3 is shortcut to rev^^^, which is shortcut to rev^1^1^1,
where rev^1 means 1st parent of rev.

> What I'd
> like to do is write something like "rev~@{2008-01-18}" (say) to get
> the same thing but with the 42 being computed automatically so that
> the commit in question is the latest possible (in commit date) before
> 2008-01-18.  Is this possible?  If so, how?  If not, might I suggest
> this as an addition for consideration?

There is no direct mapping from date to a commit. So you cannot name a
commit (specify a revision) using date. Besides commit has two dates:
author date (creation date), and commit date (modification date,
roughly).

But you can can get commit closest to given date by combining the time
limiting with limiting number of commits, as described in "Commit
limiting" in git-rev-list(1) and git-log(1) manpages.

  $ git log -n 1 --before=<date> <branch>

which would return first commit older than <date>, starting from
<branch>.

> I thought "rev@{2008-01-18}" did this, but apparently it doesn't: it
> requires a ref log of some kind, and I don't know how to make a ref
> log (git-clone doesn't seem to copy them).

Reflogs are history (log) of a position of branch tip (ref) in a local
repository. Reflog stores sha-1 of top commit before and after change,
date of change, and description of command that changed it. For
example <branch>@{1} refers to position of branch before you did
something locally to change it, were it commit, amending a commit,
or for example fetching from remote repository.

> So, is there some way I can either generate a ref log by
> systematically taking the first parent in each commit as per git-log
> --first-parent, OR (better) specify a revision directly that way?

Again: you cannot specify a commit in such way. You can find a (series
of) commits which fulfill given condition.

HTH
-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: referencing a revision at a certain date
  2008-02-11 18:40 ` Jakub Narebski
@ 2008-02-11 18:57   ` David Madore
  0 siblings, 0 replies; 4+ messages in thread
From: David Madore @ 2008-02-11 18:57 UTC (permalink / raw)
  To: GIT mailing-list; +Cc: Jakub Narebski

On Mon, Feb 11, 2008 at 10:40:39AM -0800, Jakub Narebski wrote:
> But you can can get commit closest to given date by combining the time
> limiting with limiting number of commits, as described in "Commit
> limiting" in git-rev-list(1) and git-log(1) manpages.
> 
>   $ git log -n 1 --before=<date> <branch>
> 
> which would return first commit older than <date>, starting from
> <branch>.

OK, thanks, I guess the --before part answers my question: so to get
revision "rev" back at date "YYYY-MM-DD" (always using first parents)
I'd do

git rev-list rev -n 1 --first-parent --before=YYYY-MM-DD

as in:

git checkout "`git rev-list rev -n 1 --first-parent --before=YYYY-MM-DD`"

It's a bit of a mouthful, but it does what I want (although I still
think a syntax such as rev~@{YYYY-MM-DD} or rev~{YYYY-MM-DD} or
whatever might prove useful: I imagine I'm not the first person to
wish for something of the sort).

Thanks,

-- 
     David A. Madore
    (david.madore@ens.fr,
     http://www.madore.org/~david/ )

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-11 18:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-11 18:04 referencing a revision at a certain date David Madore
2008-02-11 18:29 ` Jeff King
2008-02-11 18:40 ` Jakub Narebski
2008-02-11 18:57   ` David Madore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).