Re: behaviour of git diff, GIT_DIR & checked out tree
- From
- David Tweed <david.tweed@gmail.com>
- Date
- Sep 24, 2007, 17:09 UTC
- Message-ID
- <e1dab3980709241009q71f9a40r1f8b551b417f7475@mail.gmail.com>
- In-Reply-To
- <7v6420au43.fsf@gitster.siamese.dyndns.org>
On 9/24/07, Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> It would be illustrative if David did the following.
>
> $ cd $HOME
> $ cp -a V W
> $ rm -fr W/.git
> $ cd W
> $ GIT_DIR=$HOME/V/.git git diff @{midnight}
>
> Now we are in a random place outside of the work tree
> (i.e. "W"), and we drive "git diff" with GIT_DIR specified,
> telling it to pretend that we are at the top level of the work
> tree. So ~/W/frotz is compared with "frotz" at the top level of
> the commit (which usually is compared with ~/V/frotz), etc. But
> the directory we happen to be in very much resembles the work
> tree, so it would give identical results to
>
> $ cd $HOME/V
> $ git diff @{midnight}To separate the two issues, I did all the commands to the diff above and then removed one directory from the tree in W.
GIT_DIR=$HOME/V/.git git diff master~1 (which ought not need reflogs, right) and it gave a diff between the contents of W and master~1. I also tried with commit master@{midnight} and that also gave the difference between W and the last commit yesterday. So Junio's explanation of what's going on is right. I'm just asking if there's a way to say "the `working dir' associated with this git dir" explicitly (in the same way I can use `HEAD' to refer to the topmost commit on the current branch) when you're not somewhere within the 'working dir'. If there's not I can alias around it with "cd $HOME/V && command && cd -". (As I say, for reasons unrelated to git usage I don't actually "do work" within the tracked tree.)
Many thanks,
-- cheers, dave tweed__________________________ david.tweed@gmail.com Rm 124, School of Systems Engineering, University of Reading. "we had no idea that when we added templates we were adding a Turing- complete compile-time language." -- C++ standardisation committee