git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Scriptable mode for git bisect
@ 2022-09-23 20:54 Claus Fischer
  2022-09-24  1:44 ` Đoàn Trần Công Danh
  0 siblings, 1 reply; 8+ messages in thread
From: Claus Fischer @ 2022-09-23 20:54 UTC (permalink / raw)
  To: git


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?

***

The pourpose is to keep the source trees of two different
projects that share a few files synchronous.
My good/bad-script is a script that checks whether these
files are similar.
I want git to stop at the first change in source tree A
so that I can update source tree B with the same commit
message, then proceed to the next change in A that
changes one of those files.

Regards,

Cluas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  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 16:24   ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Đoàn Trần Công Danh @ 2022-09-24  1:44 UTC (permalink / raw)
  To: Claus Fischer; +Cc: git

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)

> 
> ***
> 
> The pourpose is to keep the source trees of two different
> projects that share a few files synchronous.
> My good/bad-script is a script that checks whether these
> files are similar.
> I want git to stop at the first change in source tree A
> so that I can update source tree B with the same commit
> message, then proceed to the next change in A that
> changes one of those files.
> 
> Regards,
> 
> Cluas

-- 
Danh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  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
  1 sibling, 1 reply; 8+ messages in thread
From: Claus Fischer @ 2022-09-24  9:32 UTC (permalink / raw)
  To: Đoàn Trần Công Danh; +Cc: git

I tried that but it turns out it does not always stop at the bad revision.

Claus

> On 24.09.2022, at 03:44, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
> 
> 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)
> 
>> 
>> ***
>> 
>> The pourpose is to keep the source trees of two different
>> projects that share a few files synchronous.
>> My good/bad-script is a script that checks whether these
>> files are similar.
>> I want git to stop at the first change in source tree A
>> so that I can update source tree B with the same commit
>> message, then proceed to the next change in A that
>> changes one of those files.
>> 
>> Regards,
>> 
>> Cluas
> 
> -- 
> Danh


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  2022-09-24  9:32   ` Claus Fischer
@ 2022-09-24  9:46     ` Đoàn Trần Công Danh
  0 siblings, 0 replies; 8+ messages in thread
From: Đoàn Trần Công Danh @ 2022-09-24  9:46 UTC (permalink / raw)
  To: Claus Fischer; +Cc: git

On 2022-09-24 11:32:52+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:
> I tried that but it turns out it does not always stop at the bad revision.

"git bisect" won't stop at the bad revision, it only left
"refs/bisect/bad" point to the first bad revision, assuming
non-alternative terms were used.

If refs/bisect/bad doesn't point to the first bad revision, your
installation is borked. Please file a bug report.

> 
> Claus
> 
> > On 24.09.2022, at 03:44, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
> > 
> > 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)
> > 
> >> 
> >> ***
> >> 
> >> The pourpose is to keep the source trees of two different
> >> projects that share a few files synchronous.
> >> My good/bad-script is a script that checks whether these
> >> files are similar.
> >> I want git to stop at the first change in source tree A
> >> so that I can update source tree B with the same commit
> >> message, then proceed to the next change in A that
> >> changes one of those files.
> >> 
> >> Regards,
> >> 
> >> Cluas
> > 
> > -- 
> > Danh
> 

-- 
Danh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  2022-09-24  1:44 ` Đoàn Trần Công Danh
  2022-09-24  9:32   ` Claus Fischer
@ 2022-09-24 16:24   ` Junio C Hamano
       [not found]     ` <69B998A9-0E3E-45F0-8733-F2A3F11625A5@clausfischer.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2022-09-24 16:24 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Claus Fischer, git, Christian Couder

Đ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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
       [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
  0 siblings, 1 reply; 8+ messages in thread
From: Đoàn Trần Công Danh @ 2022-09-25  0:59 UTC (permalink / raw)
  To: Claus Fischer; +Cc: Junio C Hamano, git, Christian Couder

On 2022-09-25 01:46:13+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:
> Well since I usually don’t have many revisions backwards, typically
> no more than 50, I can just traverse the tree backwards from main.
> I remember the last ‘bad’ revision before the good one.
> So there’s a solution for me.
> 
> Yes the bisect command puts the correct ‘first bad’ revision in its
> output but it’s surrounded by a large amount of useless text. It
> would be nice to have a ‘quiet’ flag that lets it output just the
> bad revision. Alternatively, that it ends by checking out just that
> bad revision before revert.
> 
> My problem is solved by stepping backwards to HEAD~1 each time, but
> you might consider making bisect more scriptable.

No, you don't need to parse "git bisect" output to get the "first bad"
revision. The "first bad" revision is stored in refs/bisect/bad.

And you can take the "first bad" revision in a scriptable way with:

	FIRST_BAD=$(git rev-parse --verify refs/bisect/bad)

Of course, after finishing bisecting.

-- 
Danh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Claus Fischer @ 2022-09-25 12:42 UTC (permalink / raw)
  To: Đoàn Trần Công Danh
  Cc: Junio C Hamano, git, Christian Couder

Oh thank you, I didn’t know that / didn’t grasp that while reading (apparently too fast) your previous mails.

That is way nicer.

Thank you.

Claus

> On 25.09.2022, at 02:59, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
> 
> On 2022-09-25 01:46:13+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:
>> Well since I usually don’t have many revisions backwards, typically
>> no more than 50, I can just traverse the tree backwards from main.
>> I remember the last ‘bad’ revision before the good one.
>> So there’s a solution for me.
>> 
>> Yes the bisect command puts the correct ‘first bad’ revision in its
>> output but it’s surrounded by a large amount of useless text. It
>> would be nice to have a ‘quiet’ flag that lets it output just the
>> bad revision. Alternatively, that it ends by checking out just that
>> bad revision before revert.
>> 
>> My problem is solved by stepping backwards to HEAD~1 each time, but
>> you might consider making bisect more scriptable.
> 
> No, you don't need to parse "git bisect" output to get the "first bad"
> revision. The "first bad" revision is stored in refs/bisect/bad.
> 
> And you can take the "first bad" revision in a scriptable way with:
> 
> 	FIRST_BAD=$(git rev-parse --verify refs/bisect/bad)
> 
> Of course, after finishing bisecting.
> 
> -- 
> Danh


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scriptable mode for git bisect
  2022-09-25 12:42         ` Claus Fischer
@ 2022-09-26 17:00           ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2022-09-26 17:00 UTC (permalink / raw)
  To: Claus Fischer
  Cc: Đoàn Trần Công Danh, git, Christian Couder

Claus Fischer <claus.fischer@clausfischer.com> writes:

> Oh thank you, I didn’t know that / didn’t grasp that while reading (apparently too fast) your previous mails.
>
> That is way nicer.
>
> Thank you.
>
> Claus

Now I am puzzled by your earlier response in the thread, e.g.

  https://lore.kernel.org/git/E10623C2-FF73-4E5B-AD28-C255B02F3B0F@clausfischer.com/

In any case, it is good to see that your issue has been solved.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-26 17:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
     [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

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).