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

Re: behaviour of git diff, GIT_DIR & checked out tree

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 24, 2007, 13:03 UTC
Message-ID
<Pine.LNX.4.64.0709241400410.28395@racer.site>
In-Reply-To
<e1dab3980709240545o32eeefcdkd4bc67abab0e5343@mail.gmail.com>
Hi,
On Mon, 24 Sep 2007, David Tweed wrote:
Show 13 quoted lines
> In a git tracked tree rooted at $HOME/V with
> git-dir of $HOME/V/.git, if I'm in $HOME/V then
> 
> git diff master@{midnight}
> 
> tells me the difference between the current modified files
> in the tree being tracked in V and the specified commit. In
> a different directory, OUTSIDE of $HOME/V, I tried
> 
> env GIT_DIR=$HOME/V/.git git diff master@{midnight}
> 
> to get the same effect but, whilst I do get a diff output, it
> looks like a diff of the commit against an empty tree.
Yes, this is fully expected.

The @{time} notation accesses the _reflogs_, which are purely local beasts. They are not transmitted when cloning.

The rationale: in a distributed environment, you cannot trust others' timestamps. Therefore we don't.

We can only (to a certain extent, at least) trust our _own_ timestamp. That is why we have timestamp access to the reflogs (which are purely local, as I mentioned above), but we have no way to reference commits by timestamp otherwise.

Hth, Dscho

Previous: David TweedNext: David Tweed
Message 2 of 6 in “behaviour of git diff, GIT_DIR & checked out tree”
  1. David TweedSep 24, 2007
  2. Johannes SchindelinSep 24, 2007
  3. David TweedSep 24, 2007
  4. Junio C HamanoSep 24, 2007
  5. David TweedSep 24, 2007
  6. Junio C HamanoSep 24, 2007

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.