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

referencing a revision at a certain date

From
DMDavid Madore <david.madore@ens.fr>
Date
Feb 11, 2008, 18:04 UTC
Message-ID
<20080211180424.GA4905@clipper.ens.fr>
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/ )
Next: Jeff King
Message 1 of 4 in “referencing a revision at a certain date”
  1. David MadoreFeb 11, 2008
  2. Jeff KingFeb 11, 2008
  3. Jakub NarebskiFeb 11, 2008
  4. David MadoreFeb 11, 2008

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.