git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Todd Lewis <utoddl@email.unc.edu>
Cc: git@vger.kernel.org
Subject: Re: bug report: dates on diff
Date: Thu, 06 Jul 2017 09:22:14 -0700	[thread overview]
Message-ID: <xmqqo9sxfscp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <b28bc109-b06f-0acf-960b-0b6761b0ee38@email.unc.edu> (Todd Lewis's message of "Thu, 6 Jul 2017 08:54:14 -0400")

Todd Lewis <utoddl@email.unc.edu> writes:

> [utoddl@tarna gitbug]$ git diff master@{01-01-2012} charter.txt
> warning: Log for 'master' only goes back to Thu, 6 Jul 2017 08:19:45 -0400.

What you observed is how <ref>@{<selector>} syntax is designed to
work, and is not limited to "git diff".  Any Git command e.g. "git
rev-parse master@{01-01-2012}", would and should behave the same
way.

The thing to note is that the syntax does not pay any attention to
author or committer dates recorded in the commit objects.  In fact,
if you have a ref that points at an object that is not a commit-ish,
you can still use the syntax.  If you did this, for example

    $ git config core.logallrefupdates always

    $ one=$(echo one | git hash-object --stdin -w)
    $ git update-ref refs/my/blob $one

    ... time passes ...

    $ two=$(echo two | git hash-object --stdin -w)
    $ git update-ref refs/my/blob $two

then "git show my/blob@{2.minutes.ago}" will show the blob object
your refs/my/blob ref was pointing at 2 minutes ago.

And as you may know, blobs do not record any timestamp.  So how does
this work?  

The reason why this works is because the time in <ref>@{$time}
syntax is about asking what was pointed by the <ref> back in $time
in your repository.  It does not matter what timestamp the object
that was pointed by the <ref> has (or does not have).

If you didn't create this repository back in 2012, then the syntax
"master@{01-01-2012}" that asks "Back at the beginning of 2012, what
object did the master branch point at?" does not have a sensible
answer.  That can be seen in the warning you got from Git.

Hope this clarifies.

  reply	other threads:[~2017-07-06 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06 12:54 bug report: dates on diff Todd Lewis
2017-07-06 16:22 ` Junio C Hamano [this message]
2017-07-06 17:32   ` Todd Lewis
2017-07-06 18:03     ` Junio C Hamano
2017-07-06 18:05       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqo9sxfscp.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=utoddl@email.unc.edu \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).