From: phillip.wood123@gmail.com
To: Eric Sunshine <sunshine@sunshineco.com>, phillip.wood@dunelm.org.uk
Cc: David Moberg <kaddkaka@gmail.com>, Taylor Blau <me@ttaylorr.com>,
"git@vger.kernel.org" <git@vger.kernel.org>,
Elijah Newren <newren@gmail.com>,
David Moberg <kaddkaka@gmail.com>
Subject: Re: git rebase exec make -C in worktree confuses repo root dir
Date: Tue, 5 Nov 2024 15:24:42 +0000 [thread overview]
Message-ID: <743043bf-60b7-4ed7-8cf2-4f3f972968a6@gmail.com> (raw)
In-Reply-To: <CAPig+cQmGXxDshTovdAYaZn5UMr3nvXHyH0q2HvAbaT_fhhiLQ@mail.gmail.com>
On 16/10/2024 22:12, Eric Sunshine wrote:
> On Wed, Oct 16, 2024 at 5:15 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>> On 15/10/2024 21:01, Eric Sunshine wrote:
>>>> Den tis 15 okt. 2024 kl 09:11 skrev Eric Sunshine <sunshine@sunshineco.com>:
>>>>> This looks like unintentional behavior; probably a bug. It seems to be
>>>>> triggered by `git rebase -i` setting GIT_DIR. [...]
>>>>> % git -C dir rev-parse --show-toplevel
>>>>> /.../bar
>>>>> % GIT_DIR=../../foo/.git/worktrees/bar \
>>>>> git -C dir rev-parse --show-toplevel
>>>>> /.../bar/dir
>>>>>
>>>>> The `git rev-parse --show-toplevel` invocation with GIT_DIR set is
>>>>> incorrectly returning `/.../bar/dir` rather than `/.../bar`.
>>
>> I'm about to go off the list until the 29th so I wont be working on it
>> soon either but I think the problem is that git sets $GIT_DIR when it is
>> run from a linked worktree. I've reproduced the commit message from
>> ff5b7913f0a (sequencer, stash: fix running from worktree subdir,
>> 2022-01-26) below which I think explains the problem we're seeing here.
>> Unfortunately the approach of setting $GIT_WORK_TREE used in that commit
>> won't work for exec commands as they may be run in a different worktree.
>
> Maybe. Maybe not. exec'ing a command in a worktree other than the
> current worktree may be a "don't do it if it hurts" situation. The
> same shortcoming you describe would crop up when exec'ing a command in
> a foreign repository from the one in which `git rebase -i` is being
> run. If we look at it that way ("don't do it if it hurts"), then
> perhaps a documentation update is warranted; something along the lines
> [1] which gives explains that GIT_* environment variables should be
> cleared by a Git hook if it needs to peek into a foreign repository or
> other worktree. It's not a perfectly satisfactory answer, but would at
> least (somewhat?) allay your concern about `git rebase -i` setting
> GIT_WORK_TREE automatically.
That's certainly the simplest way forward. Until 434e0636db1 (sequencer:
do not export GIT_DIR and GIT_WORK_TREE for 'exec', 2021-12-04)
we set both GIT_DIR and GIT_WORK_TREE when running an exec command. As
the message for that commit explains that behavior did not match the
scripted rebase which was the motivation to stop doing it. Unfortunately
that left us in the situation where git will sometimes set GIT_DIR when
the user has not. Ideally I'd like to understand why we're setting
GIT_DIR in setup_git_dir() when, at least at fist sight, it seems to be
unnecessary. I think that would take some time so maybe we should just
go back to setting GIT_DIR and GIT_WORK_TREE in the sequencer when
running "exec" commands.
Best Wishes
Phillip
> [1]: https://lore.kernel.org/git/pull.1457.git.1673171924727.gitgitgadget@gmail.com/
next prev parent reply other threads:[~2024-11-05 15:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 20:46 git rebase exec make -C in worktree confuses repo root dir David Moberg
2024-10-14 21:19 ` Taylor Blau
2024-10-14 21:34 ` David Moberg
2024-10-15 7:11 ` Eric Sunshine
2024-10-15 18:55 ` David Moberg
2024-10-15 20:01 ` Eric Sunshine
2024-10-16 9:15 ` Phillip Wood
2024-10-16 20:36 ` Taylor Blau
2024-10-17 21:16 ` Elijah Newren
2024-10-16 21:12 ` Eric Sunshine
2024-11-05 15:24 ` phillip.wood123 [this message]
[not found] <1730787532-3757-mlmmj-5e7be4fc@vger.kernel.org>
[not found] ` <CAL2+Mivva3AFR4of0-2d48YDDMbHiNVsUmCzhezHfe+h9faEvQ@mail.gmail.com>
[not found] ` <CAPig+cTVfNW4AFJKyGbRcy0_YJEJGcNYNx57USyp4zz1g9fSeQ@mail.gmail.com>
2024-11-28 15:07 ` Phillip Wood
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=743043bf-60b7-4ed7-8cf2-4f3f972968a6@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=kaddkaka@gmail.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sunshine@sunshineco.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;
as well as URLs for NNTP newsgroup(s).