Subject: Re: [PATCH v3 1/4] for-each-repo: test outside of repo context

From: Junio C Hamano <[email-masked]>
Date: Mon, 02 Mar 2026 10:31:52 -0800

Jeff King <[email-masked]> writes:

> On Mon, Mar 02, 2026 at 03:36:42PM +0000, Derrick Stolee via GitGitGadget wrote:
>
>>  test_description='git for-each-repo builtin'
>>  
>> +# We need to test running 'git for-each-repo' outside of a repo context.
>> +TEST_NO_CREATE_REPO=1
>> +
>>  . ./test-lib.sh
>
> Interesting. I was going to point out that this won't do what you want
> by itself, because Git will keep walking out of the trash directory and
> may find the containing repository.
>
> But it looks like this should be enough due to 614c3d8f2e (test-lib: set
> GIT_CEILING_DIRECTORIES to protect the surrounding repository,
> 2021-08-29). Supporting this case wasn't the intent of that patch, but I
> don't see any reason why it should not work reliably.

I am surprised that use of GIT_CEILING_DIRECTORIES was not done
until 2021, actually.  The reason the configuration variable was
invented for is exactly to avoid discovery processes going upward
and ending up in a repository different from what we mean to work
with.