{"thread":{"id":"22104","subject":"GIT_DIR=. for hooks?","startedAt":"2010-01-06T13:55:43Z","lastAt":"2010-01-06T17:13:39Z","messageCount":2,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"130920","messageId":"4B44965F.8040803@drmicha.warpmail.net","threadId":"22104","inReplyTo":null,"subject":"GIT_DIR=. for hooks?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-01-06T13:55:43Z","receivedAt":"2010-01-06T13:55:43Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Hi there,\n\nas it seems hooks (at least post-receive) are called with a $PWD in the\n.git dir and GIT_DIR=. exported.\n\nNow, that leads to problems when, say, diffing between the index and the\nworktree (\"Don't do that!\", I know). Without cd'ing around, the worktree\nis not found, and after \"cd ..\", the git-dir is not found.\n\nI can unset GIT_DIR or set WORK_TREE, of course, but I'm wondering\nwhether GIT_DIR=. is a sane setting at all: a git-dir in $PWD is always\nfound, and when cd'ing away that setting does not help either.\n\nMichael\n"},{"id":"130929","messageId":"7v7hrvyx4s.fsf@alter.siamese.dyndns.org","threadId":"22104","inReplyTo":"4B44965F.8040803@drmicha.warpmail.net","subject":"Re: GIT_DIR=. for hooks?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-06T17:13:39Z","receivedAt":"2010-01-06T17:13:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> I can unset GIT_DIR or set WORK_TREE, of course,\n\nThat is not just an acceptable but _the_ right way to write hooks that\ntouch the files in the work tree.  In earlier versions of git, a git-dir\nin $PWD was not found without GIT_DIR=. and hooks are supposed to work\nacross versions of git, so this behaviour got stuck.\n"}]}