git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@student.ethz.ch>
To: <perryh@pluto.rain.com>
Cc: <git@vger.kernel.org>
Subject: Re: How do I specify a revision for "git blame" by date?
Date: Thu, 14 Jun 2012 12:05:56 +0200	[thread overview]
Message-ID: <877gva1a4b.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <4fda029d.g99uVull9jgguc/Y%perryh@pluto.rain.com> (perryh@pluto.rain.com's message of "Thu, 14 Jun 2012 08:26:21 -0700")

perryh@pluto.rain.com writes:

> How do I get "git blame" to operate "as of" a particular date in
> the past, without having to manually look up the corresponding
> SHA1 using "git rev-list"?  For example, I can get a report as of
> 2011-12-29 by doing something like:
>
>   $ git rev-list --all --date-order --format="%h %ai" .
>   ...
>   7c69106 2012-01-03 ...
>   b4227af 2011-12-27 ...
>   ...
>
>   $ git blame <file> b4227af
>
> but I want to have git look up the last revision prior to the given
> date, by doing something like
>
>   $ git blame <file> @{2011-12-29}

You are looking at two different dates:

a) The dates stored within the commit object:

   - committer date, similarly shown by %ci: when the commit was created.
   - author date, shown by %ai: when "this" commit was "first created".

   These are properties of the commits, and thus part of the project
   history.  Anyone who clones the project sees the same dates.

b) The dates in the reflog, tracking the movement of *your local* refs
   (like the name implies).  The HEAD reflog tracks what *you* had
   "currently checked out" at a given time.

An automated search in (b) is possible with the @{} syntax, but note
that it tracks the *branch state*.  It says nothing about how "current"
a certain resulting commit was.  For example, if you say

  git checkout v1.6.0
  sleep 2
  git checkout -
  git show '@{1 second ago}'

you will see the commit for v1.6.0 from back in 2008.

An automated search in (a) is hard, mostly because in nonlinear history
there is not usually a single (and well-defined) commit that could be
returned.  Git could attempt to search all of your branches, like you
have done above, but which one among all commits from that date should
it pick?  Furthermore, the result set to pick from will change if you
fetch more history into your repo.

It's even worse with the author (as opposed to committer) dates: those
are not even remotely close to monotonic in most repos, because they are
kept across rewriting.  (The committer dates would be monotonic if
everyone kept their clocks in sync and avoided filter-branch tricks.)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

  reply	other threads:[~2012-06-14 10:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14 15:26 How do I specify a revision for "git blame" by date? perryh
2012-06-14 10:05 ` Thomas Rast [this message]
2012-06-15 13:02   ` perryh
2012-06-15 15:01     ` Jeff King
2012-06-15 15:53       ` Junio C Hamano
2012-06-16  4:13         ` perryh
2012-06-14 10:19 ` Andreas Schwab
2012-06-14 17:22   ` Junio C Hamano
2012-06-15 13:03   ` perryh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gva1a4b.fsf@thomas.inf.ethz.ch \
    --to=trast@student.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=perryh@pluto.rain.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).