git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git bisect start fails when stale bisect data is left behind
@ 2011-09-05 11:15 Joel Kaasinen
  2011-09-06  7:48 ` Christian Couder
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Kaasinen @ 2011-09-05 11:15 UTC (permalink / raw)
  To: git

Hi,

Just bumped into a weird bug: bisect refused to start. It seems some
previous bisect had left around state that referred to a
now-nonexistent branch.

How to reproduce:
$ echo foo > .git/BISECT_START
$ git bisect start HEAD HEAD^

Fails with "fatal: invalid reference:" on git 1.7.6.

–J

PS. Please CC me when answering, I'm not subscribed

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

* Re: [BUG] git bisect start fails when stale bisect data is left behind
  2011-09-05 11:15 [BUG] git bisect start fails when stale bisect data is left behind Joel Kaasinen
@ 2011-09-06  7:48 ` Christian Couder
  2011-09-06 16:38   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Couder @ 2011-09-06  7:48 UTC (permalink / raw)
  To: Joel Kaasinen; +Cc: git

Hi,

On Mon, Sep 5, 2011 at 1:15 PM, Joel Kaasinen <joel@zenrobotics.com> wrote:
> Hi,
>
> Just bumped into a weird bug: bisect refused to start. It seems some
> previous bisect had left around state that referred to a
> now-nonexistent branch.
>
> How to reproduce:
> $ echo foo > .git/BISECT_START
> $ git bisect start HEAD HEAD^
>
> Fails with "fatal: invalid reference:" on git 1.7.6.

Yeah, it looks like a very old behavior.
I'd suggest a simple improvement in the error message like this:

diff --git a/git-bisect.sh b/git-bisect.sh
index c21e33c..bd7155b 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -67,7 +67,8 @@ bisect_start() {
        then
                # Reset to the rev from where we started.
                start_head=$(cat "$GIT_DIR/BISECT_START")
-               git checkout "$start_head" -- || exit
+               git checkout "$start_head" -- ||
+               die "Could not checkout previous start point
'$start_head'. Try 'git bisect reset <branch>' first."
        else
                # Get rev from where we start.
                case "$head" in

If there is no objection I will provide a proper patch.

Thanks,
Christian.

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

* Re: [BUG] git bisect start fails when stale bisect data is left behind
  2011-09-06  7:48 ` Christian Couder
@ 2011-09-06 16:38   ` Junio C Hamano
  2011-09-07  4:48     ` Christian Couder
  2011-09-07  6:28     ` Joel Kaasinen
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2011-09-06 16:38 UTC (permalink / raw)
  To: Christian Couder; +Cc: Joel Kaasinen, git

Christian Couder <christian.couder@gmail.com> writes:

>> How to reproduce:
>> $ echo foo > .git/BISECT_START
>> $ git bisect start HEAD HEAD^
>>
>> Fails with "fatal: invalid reference:" on git 1.7.6.
>
> Yeah, it looks like a very old behavior.
> I'd suggest a simple improvement in the error message like this:
>
> diff --git a/git-bisect.sh b/git-bisect.sh
> index c21e33c..bd7155b 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -67,7 +67,8 @@ bisect_start() {
>         then
>                 # Reset to the rev from where we started.
>                 start_head=$(cat "$GIT_DIR/BISECT_START")
> -               git checkout "$start_head" -- || exit
> +               git checkout "$start_head" -- ||
> +               die "Could not checkout previous start point
> '$start_head'. Try 'git bisect reset <branch>' first."

I do not necessarily think this is a bug to begin with --- the user had a
bad state, and bisect stopped without doing further damage.

The real question is what the sensible suggestion/advice the new message
should give. It would have to involve bisect reset in the end to get rid
of the stale bisect state, but wouldn't the user potentially lose some
other state if s/he blindly followed the die message's suggestion and ran
"bisect reset"?

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

* Re: [BUG] git bisect start fails when stale bisect data is left behind
  2011-09-06 16:38   ` Junio C Hamano
@ 2011-09-07  4:48     ` Christian Couder
  2011-09-07  6:28     ` Joel Kaasinen
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Couder @ 2011-09-07  4:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Christian Couder, Joel Kaasinen, git

On Tuesday 06 September 2011 18:38:55 Junio C Hamano wrote:
> Christian Couder <christian.couder@gmail.com> writes:
> >> How to reproduce:
> >> $ echo foo > .git/BISECT_START
> >> $ git bisect start HEAD HEAD^
> >> 
> >> Fails with "fatal: invalid reference:" on git 1.7.6.
> > 
> > Yeah, it looks like a very old behavior.
> > I'd suggest a simple improvement in the error message like this:
> > 
> > diff --git a/git-bisect.sh b/git-bisect.sh
> > index c21e33c..bd7155b 100755
> > --- a/git-bisect.sh
> > +++ b/git-bisect.sh
> > @@ -67,7 +67,8 @@ bisect_start() {
> > 
> >         then
> >         
> >                 # Reset to the rev from where we started.
> >                 start_head=$(cat "$GIT_DIR/BISECT_START")
> > 
> > -               git checkout "$start_head" -- || exit
> > +               git checkout "$start_head" -- ||
> > +               die "Could not checkout previous start point
> > '$start_head'. Try 'git bisect reset <branch>' first."
> 
> I do not necessarily think this is a bug to begin with --- the user had a
> bad state, and bisect stopped without doing further damage.

Yeah, in fact commit f3a186ffade15f793ea17713a10e10ec4f26ff11 (bisect: improve 
error message when branch checkout fails, Sat Apr 4, 2009) already improved 
the error message, but probably didn't go far enough.

> The real question is what the sensible suggestion/advice the new message
> should give. It would have to involve bisect reset in the end to get rid
> of the stale bisect state, but wouldn't the user potentially lose some
> other state if s/he blindly followed the die message's suggestion and ran
> "bisect reset"?

When using "git bisect start" with an existing $GIT_DIR/BISECT_START file, the 
next thing we do after checking out the previous head from the BISECT_START 
file is a call to "bisect_clean_state". So all the previous bisect state is 
discarded except the previous head that is in $start_head.

If checking out the previous head fails, that probably means that the previous 
head is bad because it has been deleted.

In this case running "git bisect reset <branch>" and then "git bisect start 
..." is ok because there is no valuable state lost compared to the situation 
where "git bisect start ..." succeeded in the first place.

Of course if checking out the previous head failed because the 
$GIT_DIR/BISECT_START file has been corrupted, then it might be better to fix 
the content of this file. But anyway if we are able to fix the content of the 
file, for example by putting "foobar" in it instead of the truncated "foo" that 
made the checkout fail, then running "git bisect reset foobar" and then "git 
bisect start ..." would probably do the trick too.

It wouldn't do the trick if the $GIT_DIR/BISECT_START file also needed a 
permission change or more free space on the disc or something like that. But 
in this case we will get an hopefully meaningful error message when running 
"git bisect reset foobar" or "git bisect start ..." and we would not lose 
information.

Thanks,
Christian.

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

* Re: [BUG] git bisect start fails when stale bisect data is left behind
  2011-09-06 16:38   ` Junio C Hamano
  2011-09-07  4:48     ` Christian Couder
@ 2011-09-07  6:28     ` Joel Kaasinen
  2011-09-07 10:51       ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Joel Kaasinen @ 2011-09-07  6:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Christian Couder, git

On Tue, Sep 6, 2011 at 19:38, Junio C Hamano <gitster@pobox.com> wrote:
> I do not necessarily think this is a bug to begin with --- the user had a
> bad state, and bisect stopped without doing further damage.

Oh, actually my git-bisect man page says:

"""
   Bisect reset
       After a bisect session, to clean up the bisection state and return to
       the original HEAD, issue the following command:

           $ git bisect reset

       By default, this will return your tree to the commit that was checked
       out before git bisect start. (A new git bisect start will also do that,
       as it cleans up the old bisection state.)
"""

The parenthetical sentence seems to imply that a bisect start cleans
out the old state. The problem is that the cleaning fails when the
state is bad. (Try e.g. "git bisect start; git bisect start a b" where
a and b are valid refs.)

It's pretty much the same to me how this gets resolved. I'm fine with
a more verbose error message from bisect start.

–J

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

* Re: [BUG] git bisect start fails when stale bisect data is left behind
  2011-09-07  6:28     ` Joel Kaasinen
@ 2011-09-07 10:51       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2011-09-07 10:51 UTC (permalink / raw)
  To: Joel Kaasinen; +Cc: Christian Couder, git

Joel Kaasinen <joel@zenrobotics.com> writes:

> On Tue, Sep 6, 2011 at 19:38, Junio C Hamano <gitster@pobox.com> wrote:
>> I do not necessarily think this is a bug to begin with --- the user had a
>> bad state, and bisect stopped without doing further damage.
>
> Oh, actually my git-bisect man page says:
>
> """
>    Bisect reset
>        After a bisect session, to clean up the bisection state and return to
>        the original HEAD, issue the following command:
>
>            $ git bisect reset
>
>        By default, this will return your tree to the commit that was checked
>        out before git bisect start. (A new git bisect start will also do that,
>        as it cleans up the old bisection state.)
> """
>
> The parenthetical sentence seems to imply that a bisect start cleans
> out the old state. The problem is that the cleaning fails when the
> state is bad. (Try e.g. "git bisect start; git bisect start a b" where
> a and b are valid refs.)
>
> It's pretty much the same to me how this gets resolved. I'm fine with
> a more verbose error message from bisect start.

I do not think anybody minds "a more verbose" message. I do mind if the
suggestion the message makes were "wrong". That is what I was questioning.

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

end of thread, other threads:[~2011-09-07 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05 11:15 [BUG] git bisect start fails when stale bisect data is left behind Joel Kaasinen
2011-09-06  7:48 ` Christian Couder
2011-09-06 16:38   ` Junio C Hamano
2011-09-07  4:48     ` Christian Couder
2011-09-07  6:28     ` Joel Kaasinen
2011-09-07 10:51       ` Junio C Hamano

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