Git development
 help / color / mirror / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: GIT_WORK_TREE is not exported for post-checkout-hook
Date: Fri, 25 Sep 2026 19:11:39 +1200	[thread overview]
Message-ID: <a22c36b869d545cf3197f031a339c6b0@orcon.net.nz> (raw)
In-Reply-To: <xmqqqzisvpsq.fsf@gitster.g>

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, ".");

      reply	other threads:[~2026-09-25  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15  8:24 GIT_WORK_TREE is not exported for post-checkout-hook Phil Sainty
2026-09-16 21:39 ` Junio C Hamano
2026-09-25  7:11   ` Phil Sainty [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a22c36b869d545cf3197f031a339c6b0@orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox