From: Jeff King <peff@peff.net>
To: Samir Benmendil <me@rmz.io>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: Git rebase --exec cannot run git commands affecting other repos
Date: Fri, 11 Jan 2019 11:04:12 -0500 [thread overview]
Message-ID: <20190111160411.GD16754@sigill.intra.peff.net> (raw)
In-Reply-To: <20190110214842.dfisujzv7psx2jqe@hactar.rmz.io>
On Thu, Jan 10, 2019 at 09:48:42PM +0000, Samir Benmendil wrote:
> > If the user wants to work in a different repository, the
> > environments that tells Git about the original repository can be
> > unset to do so, which is a very much deliberately designed
> > behaviour, primarily to help those who run "git rebase" from a
> > subdirectory of the project.
>
> When run in a directory that does not have ".git" repository directory, Git
> tries to find such a directory in the parent directories to find the top of
> the working tree.
>
> That should be the case as well for `git rebase`, is it not?
Generally yes. But ".git" does not necessarily have to be connected. For
example, try this:
# a separate worktree and repo
mkdir worktree
git init --bare repo.git
git -C repo.git config core.bare false
git -C repo.git config core.worktree "$PWD/worktree"
# an unrelated repo we'll try to access
git init unrelated
# operate in the separated repo using $GIT_DIR to point to the repo
export GIT_DIR=$PWD/repo.git
cd worktree
# rebase that tries to operate in another repository
echo content >file
git add file
git commit -m file
git rebase --root -x 'cd ../unrelated && git rev-parse --git-dir'
And in fact, this case behaves the same now or with older versions of
Git (because GIT_DIR would be set either way). Likewise the less exotic
"git --git-dir=something rebase", which would set GIT_DIR in the
environment. I think there are other cases, too, where we'd internally
set GIT_DIR during repo discovery, but I don't remember all of them
offhand.
So I think the reasoning at the time was along the lines of "scripts
already should not be relying on the absence of $GIT_DIR". That said, I
do think there's an argument to be made that it generally worked before
in many common setups, even if it was not bulletproof.
And I am not sure I could construct a case where setting $GIT_DIR when
it was not already set explicitly _helps_ the "exec" command (because
if searching from the working tree does not work, then the caller of
"git rebase" would had to have set $GIT_DIR itself).
-Peff
prev parent reply other threads:[~2019-01-11 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 16:19 Git rebase --exec cannot run git commands affecting other repos Samir Benmendil
2019-01-10 18:26 ` Junio C Hamano
2019-01-10 21:48 ` Samir Benmendil
2019-01-11 16:04 ` Jeff King [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=20190111160411.GD16754@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@rmz.io \
/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).