From: Eric Sunshine <sunshine@sunshineco.com>
To: Lars Schneider <lars.schneider@autodesk.com>
Cc: Git List <git@vger.kernel.org>,
"Gumbel, Matthew K" <matthew.k.gumbel@intel.com>,
Lars Schneider <larsxschneider@gmail.com>
Subject: Re: [PATCH v1] worktree: set worktree environment in post-checkout hook
Date: Sun, 11 Feb 2018 22:27:27 -0500 [thread overview]
Message-ID: <CAPig+cQ7MRQVT-1yNF8t6RMHNrgMtYvzOToamaLO==ymxTtLYg@mail.gmail.com> (raw)
In-Reply-To: <20180210010132.33629-1-lars.schneider@autodesk.com>
On Fri, Feb 9, 2018 at 8:01 PM, <lars.schneider@autodesk.com> wrote:
> In ade546be47 (worktree: invoke post-checkout hook (unless
> --no-checkout), 2017-12-07) we taught Git to run the post-checkout hook
> in worktrees. Unfortunately, the environment of the hook was not made
> aware of the worktree. Consequently, a 'git rev-parse --show-toplevel'
> call in the post-checkout hook would return a wrong result.
>
> Fix this by setting the 'GIT_WORK_TREE' environment variable to make
> Git calls within the post-checkout hook aware of the worktree.
>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> I think this is a bug in Git 2.16. We noticed it because it caused a
> problem in Git LFS [1]. The modified test case fails with Git 2.16 and
> succeeds with this patch.
Thanks for reporting and diagnosing the problem.
I have some concerns about this patch's fix of setting GIT_WORK_TREE
unconditionally. In particular, such unconditional setting of
GIT_WORK_TREE might cause unforeseen problems. Although the
circumstances may not be quite the same, but the tale told by
86d26f240f (setup.c: re-fix d95138e (setup: set env $GIT_WORK_TREE
when .., 2015-12-20) makes me cautious.
More significantly, though, setting GIT_WORK_TREE seems too
specialized a solution. While it may "fix" Git commands invoked by the
hook, it does nothing for other commands ('cp', 'mv', etc.) which the
hook may employ.
As a review comment, I was going to suggest that you chdir() to the
new worktree directory instead of messing with GIT_WORK_TREE, but when
I tested it myself before making the suggestion, I discovered that the
issue is a bit more involved. The result is that I ended up posting a
patch series[1] to replace this one, with what I believe is a more
correct fix.
[1]: https://public-inbox.org/git/20180212031526.40039-1-sunshine@sunshineco.com/
prev parent reply other threads:[~2018-02-12 3:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-10 1:01 [PATCH v1] worktree: set worktree environment in post-checkout hook lars.schneider
2018-02-10 1:28 ` Lars Schneider
2018-02-12 3:15 ` [PATCH 0/2] worktree: change to new worktree dir before running hook(s) Eric Sunshine
2018-02-12 3:15 ` [PATCH 1/2] run-command: teach 'run_hook' about alternate worktrees Eric Sunshine
2018-02-12 20:58 ` Lars Schneider
2018-02-12 21:49 ` Eric Sunshine
2018-02-12 3:15 ` [PATCH 2/2] worktree: add: change to new worktree directory before running hook Eric Sunshine
2018-02-12 19:37 ` Junio C Hamano
2018-02-12 20:31 ` Eric Sunshine
2018-02-12 20:01 ` Lars Schneider
2018-02-13 4:42 ` Eric Sunshine
2018-02-13 4:48 ` Eric Sunshine
2018-02-13 7:27 ` Johannes Sixt
2018-02-13 7:34 ` Eric Sunshine
2018-02-15 19:18 ` [PATCH v2] worktree: add: fix 'post-checkout' not knowing new worktree location Eric Sunshine
2018-02-15 20:52 ` Junio C Hamano
2018-02-15 21:27 ` Eric Sunshine
2018-02-15 21:36 ` Junio C Hamano
2018-02-15 23:09 ` Eric Sunshine
2018-02-15 23:09 ` [PATCH v3] " Eric Sunshine
2018-02-16 16:55 ` Lars Schneider
2018-02-16 18:27 ` Eric Sunshine
2018-02-16 18:05 ` Junio C Hamano
2018-02-12 3:27 ` Eric Sunshine [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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPig+cQ7MRQVT-1yNF8t6RMHNrgMtYvzOToamaLO==ymxTtLYg@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=lars.schneider@autodesk.com \
--cc=larsxschneider@gmail.com \
--cc=matthew.k.gumbel@intel.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).