Re: how to access working tree from .git dir?

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: how to access working tree from .git dir?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:34

"Josh England" [off-list ref] writes:
In messsing around with hooks, I've discovered that not all hooks are
run in the same environment.  In particular, the current working
directory in the post-receive hook (maybe others as well) is the GIT_DIR
(.git) directory, instead of the root of the working tree (as in
pre-commit).
It is not even "instead of"; that's the only sane thing to do
for post-receive, which is in response to git-push and usually
used for a bare repository, i.e. without any work tree.

Re: how to access working tree from .git dir?

From: Josh England <hidden>
Date: 2016-06-15 22:43:34

On Fri, 2007-09-07 at 13:43 -0700, Junio C Hamano wrote:
"Josh England" [off-list ref] writes:
quoted
In messsing around with hooks, I've discovered that not all hooks are
run in the same environment.  In particular, the current working
directory in the post-receive hook (maybe others as well) is the GIT_DIR
(.git) directory, instead of the root of the working tree (as in
pre-commit).
It is not even "instead of"; that's the only sane thing to do
for post-receive, which is in response to git-push and usually
used for a bare repository, i.e. without any work tree.
I thought there was probably a sane reason for it.  That is perfectly
acceptable, but the problem still exists that there doesn't seem to be a
good way to access the top of the working tree from within the GIT_DIR.
Since I now know that post-receive has a CWD in .git, I could just use
`pwd`/../ , but I was hoping for a better (read: consistent between
hooks) solution.

-JE
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help