git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git bisect with temporary commits
@ 2015-12-14 16:37 Florian Bruhin
  2015-12-14 18:08 ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Florian Bruhin @ 2015-12-14 16:37 UTC (permalink / raw)
  To: git; +Cc: r.seitz

[-- Attachment #1: Type: text/plain, Size: 2251 bytes --]

Hi!

Today I bisected a bug which required cherry-picking an (unrelated)
compile fix later in the history so I could test the commits.

After testing a commit, I didn't reset to the commit before the
cherry-picked one, which seemed to work well, but doesn't in my minimal
example:

    $ git init
    $ echo 'good and does not compile' > file
    $ git add file && git commit -m 'good and does not compile'
    $ echo again >> file && git commit -am 'still good and does not compile'
    $ echo 'bad and compiles' > file && git commit -am 'bad and compiles'
    $ git log --oneline --decorate
    97f9214 (HEAD, master) bad and compiles
    981e109 still good and does not compile
    753ed25 good and does not compile

Now I start bisecting and cherry-pick the compile fix in master:

    $ git bisect start
    $ git bisect bad master
    $ git bisect good master~2  # 753ed25
    Bisecting: 0 revisions left to test after this (roughly 0 steps)
    [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
    florian@ws042:~/tmp/bisect1$ git cherry-pick master
    [detached HEAD b49872b] bad and compiles
     Date: Mon Dec 14 17:26:51 2015 +0100
      1 file changed, 1 insertion(+), 2 deletions(-)

Now when trying to say it's good (and forgetting to remove the
temporary commits), I get this:

    $ git bisect good
    Bisecting: a merge base must be tested
    [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile

Is this intended behaviour? Shouldn't git either do a reset to the
commit we're currently bisecting, or warn the user as it was probably
unintended to add new commits?

Currently it seems bisect just treats the current HEAD as good, and
then the bisect algorithm tries to (I think) select a commit between
the currently bisected one and the (temporary) HEAD?

When I used it today, it actually seemed to work well until I hit an
*actual* merge base, and then it started to bisect something
unexpected, which got me a bit confused ;)

Florian

-- 
http://www.the-compiler.org | me@the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: git bisect with temporary commits
  2015-12-14 16:37 git bisect with temporary commits Florian Bruhin
@ 2015-12-14 18:08 ` Andreas Schwab
  2015-12-14 18:22   ` Florian Bruhin
  2015-12-14 21:09   ` Jeff King
  0 siblings, 2 replies; 9+ messages in thread
From: Andreas Schwab @ 2015-12-14 18:08 UTC (permalink / raw)
  To: Florian Bruhin; +Cc: git, r.seitz

Florian Bruhin <me@the-compiler.org> writes:

> Now when trying to say it's good (and forgetting to remove the
> temporary commits), I get this:
>
>     $ git bisect good
>     Bisecting: a merge base must be tested
>     [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
>
> Is this intended behaviour? Shouldn't git either do a reset to the
> commit we're currently bisecting, or warn the user as it was probably
> unintended to add new commits?

You should instead tell git that HEAD^ is good, since that is what git
asked you to test.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: git bisect with temporary commits
  2015-12-14 18:08 ` Andreas Schwab
@ 2015-12-14 18:22   ` Florian Bruhin
  2015-12-14 19:21     ` Junio C Hamano
  2015-12-14 20:17     ` Andreas Schwab
  2015-12-14 21:09   ` Jeff King
  1 sibling, 2 replies; 9+ messages in thread
From: Florian Bruhin @ 2015-12-14 18:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git, r.seitz

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

* Andreas Schwab <schwab@linux-m68k.org> [2015-12-14 19:08:48 +0100]:
> Florian Bruhin <me@the-compiler.org> writes:
> 
> > Now when trying to say it's good (and forgetting to remove the
> > temporary commits), I get this:
> >
> >     $ git bisect good
> >     Bisecting: a merge base must be tested
> >     [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
> >
> > Is this intended behaviour? Shouldn't git either do a reset to the
> > commit we're currently bisecting, or warn the user as it was probably
> > unintended to add new commits?
> 
> You should instead tell git that HEAD^ is good, since that is what git
> asked you to test.

I see - but wouldn't it make more sense for a "git bisect good" (or
bad, respectively) without arguments to assume I mean the commit
bisect checked out for me, not HEAD?

I don't see any scenario where the current behaviour would make sense,
but I might be missing something.

Florian

-- 
http://www.the-compiler.org | me@the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: git bisect with temporary commits
  2015-12-14 18:22   ` Florian Bruhin
@ 2015-12-14 19:21     ` Junio C Hamano
  2015-12-14 19:38       ` Florian Bruhin
  2015-12-14 20:17     ` Andreas Schwab
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2015-12-14 19:21 UTC (permalink / raw)
  To: Florian Bruhin; +Cc: Andreas Schwab, git, r.seitz

Florian Bruhin <me@the-compiler.org> writes:

> * Andreas Schwab <schwab@linux-m68k.org> [2015-12-14 19:08:48 +0100]:
>> Florian Bruhin <me@the-compiler.org> writes:
>> 
>> > Now when trying to say it's good (and forgetting to remove the
>> > temporary commits), I get this:
>> >
>> >     $ git bisect good
>> >     Bisecting: a merge base must be tested
>> >     [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
>> >
>> > Is this intended behaviour? Shouldn't git either do a reset to the
>> > commit we're currently bisecting, or warn the user as it was probably
>> > unintended to add new commits?
>> 
>> You should instead tell git that HEAD^ is good, since that is what git
>> asked you to test.
>
> I see - but wouldn't it make more sense for a "git bisect good" (or
> bad, respectively) without arguments to assume I mean the commit
> bisect checked out for me, not HEAD?
>
> I don't see any scenario where the current behaviour would make sense,
> but I might be missing something.

When the commit "bisect" checked out is untestable, the user can
freely go to another commit, e.g. "git reset --hard HEAD^" to go
back one step, and then test it instead.  "git bisect good" has
to mark the then-current HEAD, not the commit that was checked out,
for this to work.

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

* Re: git bisect with temporary commits
  2015-12-14 19:21     ` Junio C Hamano
@ 2015-12-14 19:38       ` Florian Bruhin
  0 siblings, 0 replies; 9+ messages in thread
From: Florian Bruhin @ 2015-12-14 19:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andreas Schwab, git, r.seitz

[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]

* Junio C Hamano <gitster@pobox.com> [2015-12-14 11:21:06 -0800]:
> Florian Bruhin <me@the-compiler.org> writes:
> 
> > * Andreas Schwab <schwab@linux-m68k.org> [2015-12-14 19:08:48 +0100]:
> >> Florian Bruhin <me@the-compiler.org> writes:
> >> 
> >> > Now when trying to say it's good (and forgetting to remove the
> >> > temporary commits), I get this:
> >> >
> >> >     $ git bisect good
> >> >     Bisecting: a merge base must be tested
> >> >     [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
> >> >
> >> > Is this intended behaviour? Shouldn't git either do a reset to the
> >> > commit we're currently bisecting, or warn the user as it was probably
> >> > unintended to add new commits?
> >> 
> >> You should instead tell git that HEAD^ is good, since that is what git
> >> asked you to test.
> >
> > I see - but wouldn't it make more sense for a "git bisect good" (or
> > bad, respectively) without arguments to assume I mean the commit
> > bisect checked out for me, not HEAD?
> >
> > I don't see any scenario where the current behaviour would make sense,
> > but I might be missing something.
> 
> When the commit "bisect" checked out is untestable, the user can
> freely go to another commit, e.g. "git reset --hard HEAD^" to go
> back one step, and then test it instead.  "git bisect good" has
> to mark the then-current HEAD, not the commit that was checked out,
> for this to work.

That makes sense - thanks for the explanation!

Florian

-- 
http://www.the-compiler.org | me@the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: git bisect with temporary commits
  2015-12-14 18:22   ` Florian Bruhin
  2015-12-14 19:21     ` Junio C Hamano
@ 2015-12-14 20:17     ` Andreas Schwab
  1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2015-12-14 20:17 UTC (permalink / raw)
  To: Florian Bruhin; +Cc: git, r.seitz

Florian Bruhin <me@the-compiler.org> writes:

> I see - but wouldn't it make more sense for a "git bisect good" (or
> bad, respectively) without arguments to assume I mean the commit
> bisect checked out for me, not HEAD?

The problem is that there is nothing that marks the originally checked
out commit except by being pointed to by HEAD.  Also, testing a
different commit as the one suggested by git can be useful when skipping
over commits that are known to fail for unrelated reasons (see "Avoiding
testing a commit" in git-bisect(1)).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: git bisect with temporary commits
  2015-12-14 18:08 ` Andreas Schwab
  2015-12-14 18:22   ` Florian Bruhin
@ 2015-12-14 21:09   ` Jeff King
  2015-12-14 21:17     ` Junio C Hamano
  1 sibling, 1 reply; 9+ messages in thread
From: Jeff King @ 2015-12-14 21:09 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Florian Bruhin, git, r.seitz

On Mon, Dec 14, 2015 at 07:08:48PM +0100, Andreas Schwab wrote:

> Florian Bruhin <me@the-compiler.org> writes:
> 
> > Now when trying to say it's good (and forgetting to remove the
> > temporary commits), I get this:
> >
> >     $ git bisect good
> >     Bisecting: a merge base must be tested
> >     [981e1093dae24b37189bcba2dd848b0c3388080c] still good and does not compile
> >
> > Is this intended behaviour? Shouldn't git either do a reset to the
> > commit we're currently bisecting, or warn the user as it was probably
> > unintended to add new commits?
> 
> You should instead tell git that HEAD^ is good, since that is what git
> asked you to test.

Another alternative is to use "git cherry-pick -n" to create a working
tree state that you can test, but leave HEAD at the original commit.
Then "git bisect good" does the right thing.

It's the same principle and I don't think there is a reason to prefer
one over the other. I just find it harder to screw up, as I usually
script the build/test, so I can stick the cherry-pick there and not have
to remember it on each "good/bad" report.

-Peff

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

* Re: git bisect with temporary commits
  2015-12-14 21:09   ` Jeff King
@ 2015-12-14 21:17     ` Junio C Hamano
  2015-12-14 21:26       ` Jeff King
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2015-12-14 21:17 UTC (permalink / raw)
  To: Jeff King; +Cc: Andreas Schwab, Florian Bruhin, git, r.seitz

Jeff King <peff@peff.net> writes:

>> You should instead tell git that HEAD^ is good, since that is what git
>> asked you to test.
>
> Another alternative is to use "git cherry-pick -n" to create a working
> tree state that you can test, but leave HEAD at the original commit.
> Then "git bisect good" does the right thing.

I was about to say the same, and "bisect good" at that point does
mark the correct commit, but does it always do the right thing?  I
think the procedure must be

	git cherry-pick -n $the_fixup
        test
        git reset --hard
        git bisect good (or bad)

for it to always work, which is not all that different from

	git cherry-pick $the_fixup
        test
        git reset --hard HEAD^
        git bisect good (or bad)

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

* Re: git bisect with temporary commits
  2015-12-14 21:17     ` Junio C Hamano
@ 2015-12-14 21:26       ` Jeff King
  0 siblings, 0 replies; 9+ messages in thread
From: Jeff King @ 2015-12-14 21:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andreas Schwab, Florian Bruhin, git, r.seitz

On Mon, Dec 14, 2015 at 01:17:03PM -0800, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> >> You should instead tell git that HEAD^ is good, since that is what git
> >> asked you to test.
> >
> > Another alternative is to use "git cherry-pick -n" to create a working
> > tree state that you can test, but leave HEAD at the original commit.
> > Then "git bisect good" does the right thing.
> 
> I was about to say the same, and "bisect good" at that point does
> mark the correct commit, but does it always do the right thing?  I
> think the procedure must be
> 
> 	git cherry-pick -n $the_fixup
>         test
>         git reset --hard
>         git bisect good (or bad)

Hmm, you're right. I assumed "git bisect good" would do the equivalent
of "git checkout -f", but it doesn't. I guess it has been long enough
since I have had to cherry-pick a fix that I completely forgot that bit.

It might be convenient if bisect did pass "-f" to checkout, but I guess
it would also be destructive if you had hand-tweaks you forgot to save.

-Peff

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

end of thread, other threads:[~2015-12-14 21:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-14 16:37 git bisect with temporary commits Florian Bruhin
2015-12-14 18:08 ` Andreas Schwab
2015-12-14 18:22   ` Florian Bruhin
2015-12-14 19:21     ` Junio C Hamano
2015-12-14 19:38       ` Florian Bruhin
2015-12-14 20:17     ` Andreas Schwab
2015-12-14 21:09   ` Jeff King
2015-12-14 21:17     ` Junio C Hamano
2015-12-14 21:26       ` Jeff King

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).