{"thread":{"id":"3310","subject":"[PATCH] Properly git-bisect reset after bisecting from non-master head","startedAt":"2006-02-12T16:06:14Z","lastAt":"2006-02-12T20:35:29Z","messageCount":4,"participants":["Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15975","messageId":"20060212160614.GV31278@pasky.or.cz","threadId":"3310","inReplyTo":null,"subject":"[PATCH] Properly git-bisect reset after bisecting from non-master head","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-02-12T16:06:14Z","receivedAt":"2006-02-12T16:06:14Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"git-bisect reset without an argument would return to master even\nif the bisecting started at a non-master branch. This patch makes\nit save the original branch name to .git/head-name and restore it\nafterwards.\n\nThis is also compatible with Cogito and cg-seek, so cg-status will\nshow that we are seeked on the bisect branch and cg-reset will\nproperly restore the original branch.\n\ngit-bisect start will refuse to work if it is not on a bisect but\n.git/head-name exists; this is to protect against conflicts with\nother seeking tools.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\ncommit 143fc0c9a04ca38a70fbd882e38620f566415b6c\ntree c93f93a984c00cfa08bbb9cb46bd1c6ba2c82de0\nparent 8dcc626cd144b2c6eae2a299242bbbe905cb0059\nauthor Petr Baudis <pasky@suse.cz> Sun, 12 Feb 2006 16:57:39 +0100\ncommitter Petr Baudis <xpasky@machine.or.cz> Sun, 12 Feb 2006 16:57:39 +0100\n\n git-bisect.sh |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 51e1e44..3c024aa 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -49,9 +49,16 @@ bisect_start() {\n \tdie \"Bad HEAD - I need a symbolic ref\"\n \tcase \"$head\" in\n \trefs/heads/bisect*)\n-\t\tgit checkout master || exit\n+\t\tif [ -s \"$GIT_DIR/head-name\" ]; then\n+\t\t    branch=`cat \"$GIT_DIR/head-name\"`\n+\t\telse\n+\t\t    branch=master\n+\t        fi\n+\t\tgit checkout $branch || exit\n \t\t;;\n \trefs/heads/*)\n+\t\t[ -s \"$GIT_DIR/head-name\" ] && die \"won't bisect on seeked tree\"\n+\t\techo \"$head\" | sed 's#^refs/heads/##' >\"$GIT_DIR/head-name\"\n \t\t;;\n \t*)\n \t\tdie \"Bad HEAD - strange symbolic ref\"\n@@ -159,7 +166,11 @@ bisect_visualize() {\n \n bisect_reset() {\n \tcase \"$#\" in\n-\t0) branch=master ;;\n+\t0) if [ -s \"$GIT_DIR/head-name\" ]; then\n+\t       branch=`cat \"$GIT_DIR/head-name\"`\n+\t   else\n+\t       branch=master\n+\t   fi ;;\n \t1) test -f \"$GIT_DIR/refs/heads/$1\" || {\n \t       echo >&2 \"$1 does not seem to be a valid branch\"\n \t       exit 1\n@@ -170,7 +181,7 @@ bisect_reset() {\n \tesac\n \tgit checkout \"$branch\" &&\n \trm -fr \"$GIT_DIR/refs/bisect\"\n-\trm -f \"$GIT_DIR/refs/heads/bisect\"\n+\trm -f \"$GIT_DIR/refs/heads/bisect\" \"$GIT_DIR/head-name\"\n \trm -f \"$GIT_DIR/BISECT_LOG\"\n }\n \n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nOf the 3 great composers Mozart tells us what it's like to be human,\nBeethoven tells us what it's like to be Beethoven and Bach tells us\nwhat it's like to be the universe.  -- Douglas Adams\n"},{"id":"15990","messageId":"7vhd749xtl.fsf@assigned-by-dhcp.cox.net","threadId":"3310","inReplyTo":"20060212160614.GV31278@pasky.or.cz","subject":"Re: [PATCH] Properly git-bisect reset after bisecting from non-master head","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-12T19:33:26Z","receivedAt":"2006-02-12T19:33:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> diff --git a/git-bisect.sh b/git-bisect.sh\n> index 51e1e44..3c024aa 100755\n> --- a/git-bisect.sh\n> +++ b/git-bisect.sh\n> @@ -49,9 +49,16 @@ bisect_start() {\n>  \tdie \"Bad HEAD - I need a symbolic ref\"\n>  \tcase \"$head\" in\n>  \trefs/heads/bisect*)\n> -\t\tgit checkout master || exit\n> +\t\tif [ -s \"$GIT_DIR/head-name\" ]; then\n> +\t\t    branch=`cat \"$GIT_DIR/head-name\"`\n> +\t\telse\n> +\t\t    branch=master\n> +\t        fi\n> +\t\tgit checkout $branch || exit\n>  \t\t;;\n>  \trefs/heads/*)\n> +\t\t[ -s \"$GIT_DIR/head-name\" ] && die \"won't bisect on seeked tree\"\n> +\t\techo \"$head\" | sed 's#^refs/heads/##' >\"$GIT_DIR/head-name\"\n>  \t\t;;\n\nHmph.  It seems that $GIT_DIR/head-name might want to be a\nsymbolic ref?\n\nBut other than that the patch looks sane, being able to go back\nto the original branch, and preventing starting to bisect while\nbisecting are useful and safe changes.  Thanks.\n"},{"id":"15992","messageId":"20060212194146.GX31278@pasky.or.cz","threadId":"3310","inReplyTo":"7vhd749xtl.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Properly git-bisect reset after bisecting from non-master head","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-02-12T19:41:46Z","receivedAt":"2006-02-12T19:41:46Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sun, Feb 12, 2006 at 08:33:26PM CET, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n> Petr Baudis <pasky@suse.cz> writes:\n> \n> > diff --git a/git-bisect.sh b/git-bisect.sh\n> > index 51e1e44..3c024aa 100755\n> > --- a/git-bisect.sh\n> > +++ b/git-bisect.sh\n> > @@ -49,9 +49,16 @@ bisect_start() {\n> >  \tdie \"Bad HEAD - I need a symbolic ref\"\n> >  \tcase \"$head\" in\n> >  \trefs/heads/bisect*)\n> > -\t\tgit checkout master || exit\n> > +\t\tif [ -s \"$GIT_DIR/head-name\" ]; then\n> > +\t\t    branch=`cat \"$GIT_DIR/head-name\"`\n> > +\t\telse\n> > +\t\t    branch=master\n> > +\t        fi\n> > +\t\tgit checkout $branch || exit\n> >  \t\t;;\n> >  \trefs/heads/*)\n> > +\t\t[ -s \"$GIT_DIR/head-name\" ] && die \"won't bisect on seeked tree\"\n> > +\t\techo \"$head\" | sed 's#^refs/heads/##' >\"$GIT_DIR/head-name\"\n> >  \t\t;;\n> \n> Hmph.  It seems that $GIT_DIR/head-name might want to be a\n> symbolic ref?\n\nThat probably isn't a bad idea per se, but I can't think of anything\nwhich that would improve either, and this has the plus of being\ncompatible with Cogito.\n\nAnyway, if you want a symref, you should probably give it a different\nname.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nOf the 3 great composers Mozart tells us what it's like to be human,\nBeethoven tells us what it's like to be Beethoven and Bach tells us\nwhat it's like to be the universe.  -- Douglas Adams\n"},{"id":"15993","messageId":"7vd5hs9uy6.fsf@assigned-by-dhcp.cox.net","threadId":"3310","inReplyTo":"20060212194146.GX31278@pasky.or.cz","subject":"Re: [PATCH] Properly git-bisect reset after bisecting from non-master head","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-12T20:35:29Z","receivedAt":"2006-02-12T20:35:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>> Hmph.  It seems that $GIT_DIR/head-name might want to be a\n>> symbolic ref?\n>\n> That probably isn't a bad idea per se, but I can't think of anything\n> which that would improve either, and this has the plus of being\n> compatible with Cogito.\n\nAh, I missed that part, that \"head-name\" is being used by Cogito\nand you used that format.\n"}]}