git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Robert Dailey <rcdailey.lists@gmail.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: Why do dates in refspecs require the reflog?
Date: Tue, 30 Dec 2014 12:31:00 -0800	[thread overview]
Message-ID: <xmqq61csswvv.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAHd499Cvy=zi=9utoZ2bEgdSUTjkveHMP2OvVFPBHq7W2MuoZQ@mail.gmail.com> (Robert Dailey's message of "Tue, 30 Dec 2014 14:12:15 -0600")

Robert Dailey <rcdailey.lists@gmail.com> writes:

> I was surprised to find today that the following didn't work as expected:
>
> $ git show master@{"1 year ago"}:Path/To/File.h
>
> It gave me the following warning which did not make the problem obvious at all:
> warning: Log for 'master' only goes back to Mon, 8 Sep 2014 12:08:44 -0500.
>
> What it is trying to tell me (and I only found this out after a lot of
> poking and prodding around Google) is that I can't refer to a commit
> by date if it extends beyond the range of the reflog.
>
> I don't understand why this requirement is in place. Each commit has a
> time stamp, so in theory it should be possible to calculate an
> absolute date from the duration specified in the refspec and grab the
> commit from `git log` from that.

The reason is because the dates on the commit object itself do not
have anything to do with the question you are asking with the
"@{date}" notation.  master@{at-this-time} notation specifies the
commit that was at the tip of your master branch at the specified
time, and that information can _only_ come from your own reflogs.

If you did this in your copy of git.git repository today:

    $ git checkout -b test e83c5163316f89bfbd
    $ sleep 3600
    $ git reset --hard master
    $ git show test@{20.minutes.ago}

you will see e83c516, even though that commit is almost 10 years
old.  Now what was at the tip of your "test" branch on April 7th,
2005?  The answer is "nothing", as most likely your 'test' branch
did not exist back then.

And that is why "git show test@{2005/04/07}" will not (and should
not) look at the timestamps in commit objects.

  parent reply	other threads:[~2014-12-30 20:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30 20:12 Why do dates in refspecs require the reflog? Robert Dailey
2014-12-30 20:16 ` Stefan Beller
2014-12-30 20:31 ` Junio C Hamano [this message]
2014-12-30 20:47 ` Junio C Hamano
2014-12-30 20:52 ` Michael Haggerty
2014-12-30 20:55   ` Junio C Hamano
2014-12-30 21:39     ` Robert Dailey
2014-12-31  1:26       ` Jeff King
2014-12-30 21:49     ` Michael Haggerty

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=xmqq61csswvv.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rcdailey.lists@gmail.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).