Hi Junio,
On 2026-09-17 09:39, Junio C Hamano wrote:
The attached patch would export GIT_WORK_TREE when
worktree exists and GIT_DIR would also be exported,
Thanks for looking at this. I've just tested your patch
and it seems to me that discovery.worktree may not be
(or at least may not /always/ be) the right value. With
the patch I see the following in my script's environment:
GIT_DIR=/path/to/repo/.git/worktrees/name
GIT_WORK_TREE='.'
Moreover, I see the '.' value regardless of which sub-
directory of the worktree I was in at the time.
"git rev-parse --show-toplevel" still returns the CWD
(which may now be because it's the path for the explicit
'.' value?)
I can see a few places in setup.c where that value is
being set:
./setup.c:510: setenv(GIT_WORK_TREE_ENVIRONMENT, ".", 1);
./setup.c:1213: repo_discovery_set_worktree(discovery, ".");
./setup.c:1269: repo_discovery_set_worktree(discovery, ".");