Subject: Re: [PATCH] bisect: allow to run from subdirectories

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Tue, 22 Jun 2021 17:27:27 +0200

On Mon, Jun 21 2021, Ævar Arnfjörð Bjarmason wrote:

> On Mon, Jun 21 2021, Roland Hieber wrote:
>
>> On Sun, Jun 20, 2021 at 10:10:10PM -0400, Eric Sunshine wrote:
>>> On Sun, Jun 20, 2021 at 10:00 PM brian m. carlson
>>> <[email-masked]> wrote:
>>> > On 2021-06-21 at 00:35:49, Ævar Arnfjörð Bjarmason wrote:
>>> > > On Sun, Jun 20 2021, Roland Hieber wrote:
>>> > > > Currently, calling 'git bisect' from a directory other than the top
>>> > > > level of a repository only comes up with an error message:
>>> > > >
>>> > > >     You need to run this command from the toplevel of the working tree.
>>> > >
>>> > > How does this affect out-of-tree scripts that will be run with "git
>>> > > bisect run", is the cwd set to the root as they now might expect git to
>>> > > check, or whatever subdirectory you ran the "run" from?
>>> >
>>> > As for the idea itself, I think it's a good one assuming everything
>>> > continues to work.  It will certainly be more convenient for a lot of
>>> > people.
>>> 
>>> There have been multiple patches sent to the project over the years
>>> with the same purpose. One problem, I believe, which has never been
>>> fully addressed is what happens when the subdirectory from which
>>> git-bisect is run gets deleted as part of the bisection.
>>> 
>>> Here are a couple recent threads triggered by previous such patches
>>> (but there are probably several more):
>>> 
>>> https://lore.kernel.org/git/[email-masked]/
>>> https://lore.kernel.org/git/[email-masked]/
>>
>> Ah, thanks for explaining the problem. Would a patch that adds a short
>> explanatory comment in git-bisect.sh on the matter help to prevent
>> people sending such patches?
>
> Having skimmed the linked discussions I don't think the consensus is
> that this shouldn't exist, but that someone who wants it should do some
> research on the relevant edge cases, come up with test cases for them,
> discuss the trade-offs in a commit message etc.
>
> I for one would welcome such a feature, it's often annoyed me, it should
> just work like "rebase exec" in that a "run" script should cd to the
> root, but (as discussed in the linked threads) I don't see why we'd
> prevent it any more than several other commands that already have this
> edge case, but don't explicitly prevent this.

There's also a related issue: It's not just "git bisect start" etc. that
have this problem, but also "git bisect log". No matter what we do with
run etc.

I see no reason for why "log" should not locate the relevant log in the
.git directory, same for "view", also "good", "bad" etc. E.g. one might
start a bisect session in one terminal, and be cd'd into the 't/'
directory in another, and then couldn't run "good/bad" there.