git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
Cc: Claus Fischer <claus.fischer@clausfischer.com>,
	git@vger.kernel.org,
	Christian Couder <christian.couder@gmail.com>
Subject: Re: Scriptable mode for git bisect
Date: Sat, 24 Sep 2022 09:24:29 -0700	[thread overview]
Message-ID: <xmqqwn9srb9e.fsf@gitster.g> (raw)
In-Reply-To: <Yy5g80OtVG4op8L1@danh.dev> (=?utf-8?B?IsSQb8OgbiBUcuG6p24g?= =?utf-8?B?Q8O0bmc=?= Danh"'s message of "Sat, 24 Sep 2022 08:44:19 +0700")

Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:

> On 2022-09-23 22:54:03+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:
>> 
>> Dear Git maintainers,
>> 
>> I have looked at the manpage of git bisect but have not found
>> what I need:
>> I would like git bisect not just to report the 'bad' revision
>> within a bunch of text but instead either stop at the first
>> bad revision (the last good will then be HEAD~1) or report
>> it in a scriptable way, i.e.
>> 
>>   BADHEAD=$(git bisect run --shut-up-and-report-the-bad)
>> 
>> Have I overlooked anything?
>
> After running "git bisect run"
> You can take its revisions with:
>
> 	BADHEAD=$(git rev-parse --verify refs/bisect/bad)

Christian, who invested quite a lot of work in the command (cc'ed),
may have more tricks up his sleeve.

You can also check .git/BISECT_LOG; the value of refs/bisect/bad is
the source of truth, as the final verdict message given by the
command (cf. builtin/bisect--helper.c::bisect_successful() that
reads from "refs/bisect/$bad" which is called when "the first bad
commit" is found by bisect.c::bisect_next_all()).

One thing that may confuse a new user is that the commit HEAD, when
"git bisect" finds the first bad commit, may not be a bad one.  You
start from a longer streatch of history (time flows from left to right,
B and G are known bad and good ones, ? are not known)

               ?---?---?
              /         \
    -----G---?---?---?---?---?---B

and then go narrowing down by answering "is this one good?"
questions.  Answering "Good" paints all its unknown ancestors as
"Good".  The final step may look like this, where the sole '?' is
the commit that is checked out to be tested:

               G---G---G
              /         \
    -----G---G---G---?---B---B---B

And the answer to the final step may be "good" or "bad".  If it is
"good", then the first bad commit would be its child commit, which
is a merge commit that introduced the badness into the history.

But still, the first bad commit is found at refs/bisect/bad

  parent reply	other threads:[~2022-09-24 16:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 20:54 Scriptable mode for git bisect Claus Fischer
2022-09-24  1:44 ` Đoàn Trần Công Danh
2022-09-24  9:32   ` Claus Fischer
2022-09-24  9:46     ` Đoàn Trần Công Danh
2022-09-24 16:24   ` Junio C Hamano [this message]
     [not found]     ` <69B998A9-0E3E-45F0-8733-F2A3F11625A5@clausfischer.com>
2022-09-25  0:59       ` Đoàn Trần Công Danh
2022-09-25 12:42         ` Claus Fischer
2022-09-26 17:00           ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwn9srb9e.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=christian.couder@gmail.com \
    --cc=claus.fischer@clausfischer.com \
    --cc=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).