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