Subject: Re: [PATCH] bisect--helper: warn if we are assuming an unlikely pathspec

From: Junio C Hamano <[email-masked]>
Date: Sun, 01 May 2022 23:22:01 -0700

Bagas Sanjaya <[email-masked]> writes:

> On 5/1/22 19:29, Chris Down wrote:
>> In order to avoid this, emit a warning when we are assuming an argument
>> is a pathspec, but no such path exists in the checkout and this doesn't
>> look like a pathspec according to looks_like_pathspec:
>> 
>>     $ git bisect start d93ff48803f0 v6.3
>>     warning: assuming 'v6.3' is a path
>>     $
>> 
>
> For completeness, we can say 'If this is incorrect, abort the current
> bisection with "git bisect reset" and rerun with correct commit-ish.'.

We certainly can, but I am not sure how much it helps.

Even though I understand that the original end-user confusion
happened to come from taking what the user thought was a revision as
pathspec, I think it is a mistake to build the "warning" UI around
it.

Stepping back a bit, there are "git bisect" invocations that compute
and check out the commit to be tested, and there are "git bisect"
invocations that only advance the internal state a bit but not yet
become ready to offer the first commit to be tested.  The problem in
the current UI is that we are fairly chatty once we start bisecting,
but until we receive enough information to start bisecting, we are
fairly silent.

Even if the user did not use the lazy short-hand form of "bisect
start" with bad and good commits at all, after saying "git bisect
good <X>" (read: it is a state that made a bit of progress but still
not ready, because the command wants to see at least one bad commit,
too), wouldn't it be nice if the user is told what state the command
is in?  Perhaps we can give some feedback _before_ we are ready to
compute bisection?

A model dialogue may go like this.

    $ git bisect start -- bin/
    info: bisect waiting for good and bad commits.
    $ git bisect good master
    info: bisect waiting for a bad commit, one good commit known.
    $ git bisect good maint
    info: bisect waiting for a bad commit, two good commits known.
    $ git bisect bad next
    Bisecting: ...

Then the exchange for the lazy short-hand form of "bisect start"
would fall out quite naturally.

    $ git bisect start d93ff48803f0 -- v6.3
    info: bisect waiting for a good commit, one bad commit known.

For a bonus point, we may want to also say something on these
"info:" lines that we were given a pathspec.

It would also be a good idea to add a new subcommand "git bisect status"
to recompute the state (i.e. what it is waiting for and what it
already knows) when the user forgets, which can happen quite often.

With such a bonus feature, the exchange might go like this:

    $ git bisect start seen
    info: bisect waiting for a good commit, a bad commit known.
    $ git reset --hard maint ;# choose an older point, hoping it is good.
    $ make test
    ... pages of output scrolls the "info:" out of window ...
    $ git bisect status
    info: bisect waiting for a good commit, a bad commit known.
    $ git bisect bad maint
    info: bisect waiting for a good commit, a bad commit known.
    $ git reset --hard v1.0 ;# an even older point, hoping it is good.
    $ make test
    ... again pages of output ...
    $ git bisect good v1.0
    Bisecting ...

Hmm?