{"thread":{"id":"66451","subject":"git-bisect(1) next after finding the commit","startedAt":"2026-10-02T21:49:06Z","lastAt":"2026-10-05T12:38:02Z","messageCount":7,"participants":["Alejandro Colomar","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"554014","messageId":"asAbOSQ4BkuCTPY5@debian","threadId":"66451","inReplyTo":null,"subject":"git-bisect(1) next after finding the commit","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2026-10-02T21:49:01Z","receivedAt":"2026-10-02T21:49:06Z","isPatch":false,"body":"Hi!\n\nIs there a plumbing command for retrieving the bisected commit after\na git-bisect(1) session has successfully found it (and of course before\nresetting the session)?\n\nI expected `git bisect next` would bring me to it, and then I'd rev-list\nHEAD -1, but it doesn't bring me to it.\n\n\nHave a lovely day!\nAlex\n\n-- \n<https://www.alejandro-colomar.es>\n"},{"id":"554016","messageId":"20261002221154.GA833115@coredump.intra.peff.net","threadId":"66451","inReplyTo":"asAbOSQ4BkuCTPY5@debian","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-10-02T22:11:54Z","receivedAt":"2026-10-02T22:12:03Z","isPatch":false,"body":"On Fri, Oct 02, 2026 at 11:49:01PM +0200, Alejandro Colomar wrote:\n\n> Is there a plumbing command for retrieving the bisected commit after\n> a git-bisect(1) session has successfully found it (and of course before\n> resetting the session)?\n> \n> I expected `git bisect next` would bring me to it, and then I'd rev-list\n> HEAD -1, but it doesn't bring me to it.\n\nI'm not 100% sure, but I think \"git show bisect/bad\" should work.\n\nAs the bisection progresses, we advance a single refs/bisect/bad from\nthe bottom of the range (the top is multiple refs/bisect/good-* refs).\nSo at the end, it should point to the blamed commit.\n\n-Peff\n"},{"id":"554019","messageId":"xmqqece7vimq.fsf@gitster.g","threadId":"66451","inReplyTo":"20261002221154.GA833115@coredump.intra.peff.net","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-02T22:32:13Z","receivedAt":"2026-10-02T22:32:16Z","isPatch":false,"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, Oct 02, 2026 at 11:49:01PM +0200, Alejandro Colomar wrote:\n>\n>> Is there a plumbing command for retrieving the bisected commit after\n>> a git-bisect(1) session has successfully found it (and of course before\n>> resetting the session)?\n>> \n>> I expected `git bisect next` would bring me to it, and then I'd rev-list\n>> HEAD -1, but it doesn't bring me to it.\n>\n> I'm not 100% sure, but I think \"git show bisect/bad\" should work.\n>\n> As the bisection progresses, we advance a single refs/bisect/bad from\n> the bottom of the range (the top is multiple refs/bisect/good-* refs).\n> So at the end, it should point to the blamed commit.\n\nThe only code that gives \"is the first .* commit\" message is this bit\nin bisect.c:\n\n\tif (oideq(bisect_rev, current_bad_oid)) {\n\t\tres = error_if_skipped_commits(tried, current_bad_oid);\n\t\tif (res)\n\t\t\tgoto cleanup;\n\t\tprintf(\"%s is the first '%s' commit\\n\", oid_to_hex(bisect_rev),\n\t\t\tterm_bad);\n\nit is fed bisect_rev only when it is the same as current_bad_oid,\nwhich was read from \"refs/bisect/bad\".  So I think you are right.\n\n\n[Footnote]\n\nThere is a last-step optimization that made me double check the\ncode, but the optimization is about not bothering to move HEAD and\nnot moving refs/bisect/bad pointer.\n\nWe have a three-topic branch X, X is at the tip, X~1 at the middle\nand X-2 at the bottom.  X~3 is on the mainline.\n\n----- X~3 ---- X~2 ---- X~1 ---- X\n\nWe found X~2 to be good. X is bad.\n\n  $ git bisect start X X~2\n\nWe are asked to test X~1.\n\n * It turns out to be bad.  We move bisect/bad to X~1.  And then we\n   report that X~1 is the first bad commit.\n\n * Or it turns out to be good.  Then we report that X is the first\n   bad commit.  But we do not move HEAD and checkout X.\n"},{"id":"554044","messageId":"asCY8kLEV4OAG1BG@debian","threadId":"66451","inReplyTo":"20261002221154.GA833115@coredump.intra.peff.net","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2026-10-03T05:59:43Z","receivedAt":"2026-10-03T05:59:48Z","isPatch":false,"body":"Hi Jeff,\n\n> Date: 2026-10-02 18:11:54-0400\n> From: Jeff King <peff@peff.net>\n>\n> On Fri, Oct 02, 2026 at 11:49:01PM +0200, Alejandro Colomar wrote:\n> \n> > Is there a plumbing command for retrieving the bisected commit after\n> > a git-bisect(1) session has successfully found it (and of course before\n> > resetting the session)?\n> > \n> > I expected `git bisect next` would bring me to it, and then I'd rev-list\n> > HEAD -1, but it doesn't bring me to it.\n> \n> I'm not 100% sure, but I think \"git show bisect/bad\" should work.\n\nThanks!  It works.\n\nI guess the plumbing version of it would be\n\tgit rev-list -1 bisect/bad\nright?\n\n> As the bisection progresses, we advance a single refs/bisect/bad from\n> the bottom of the range (the top is multiple refs/bisect/good-* refs).\n> So at the end, it should point to the blamed commit.\n> \n> -Peff\n\n\nHave a lovely day!\nAlex\n\n-- \n<https://www.alejandro-colomar.es>\n"},{"id":"554045","messageId":"asCaIXYuZFdlFU0J@debian","threadId":"66451","inReplyTo":"xmqqece7vimq.fsf@gitster.g","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2026-10-03T06:03:18Z","receivedAt":"2026-10-03T06:03:23Z","isPatch":false,"body":"Hi Junio,\n\n> Date: 2026-10-02 15:32:13-0700\n> From: Junio C Hamano <gitster@pobox.com>\n>\n> Jeff King <peff@peff.net> writes:\n> \n> > On Fri, Oct 02, 2026 at 11:49:01PM +0200, Alejandro Colomar wrote:\n> >\n> >> Is there a plumbing command for retrieving the bisected commit after\n> >> a git-bisect(1) session has successfully found it (and of course before\n> >> resetting the session)?\n> >> \n> >> I expected `git bisect next` would bring me to it, and then I'd rev-list\n> >> HEAD -1, but it doesn't bring me to it.\n> >\n> > I'm not 100% sure, but I think \"git show bisect/bad\" should work.\n> >\n> > As the bisection progresses, we advance a single refs/bisect/bad from\n> > the bottom of the range (the top is multiple refs/bisect/good-* refs).\n> > So at the end, it should point to the blamed commit.\n> \n> The only code that gives \"is the first .* commit\" message is this bit\n> in bisect.c:\n> \n> \tif (oideq(bisect_rev, current_bad_oid)) {\n> \t\tres = error_if_skipped_commits(tried, current_bad_oid);\n> \t\tif (res)\n> \t\t\tgoto cleanup;\n> \t\tprintf(\"%s is the first '%s' commit\\n\", oid_to_hex(bisect_rev),\n> \t\t\tterm_bad);\n> \n> it is fed bisect_rev only when it is the same as current_bad_oid,\n> which was read from \"refs/bisect/bad\".  So I think you are right.\n\nThanks for confirming!  It certainly works for me (I've tested it).\n\n> [Footnote]\n> \n> There is a last-step optimization that made me double check the\n> code, but the optimization is about not bothering to move HEAD and\n> not moving refs/bisect/bad pointer.\n> \n> We have a three-topic branch X, X is at the tip, X~1 at the middle\n> and X-2 at the bottom.  X~3 is on the mainline.\n> \n> ----- X~3 ---- X~2 ---- X~1 ---- X\n> \n> We found X~2 to be good. X is bad.\n> \n>   $ git bisect start X X~2\n> \n> We are asked to test X~1.\n> \n>  * It turns out to be bad.  We move bisect/bad to X~1.  And then we\n>    report that X~1 is the first bad commit.\n> \n>  * Or it turns out to be good.  Then we report that X is the first\n>    bad commit.  But we do not move HEAD and checkout X.\n\nIndeed, this optimization is what surprised me.  I expected it would\nmove the HEAD as with every other git-bisect(1) step, but the last one\ndidn't move it.  I can live with it, FWIW, since bisect/bad contains all\nthe information I need (and anyway, I will move the HEAD myself, so I\ndon't need the HEAD in any specific position).  It was just surprising.\n\n:)\n\n\nHave a lovely day!\nAlex\n\n-- \n<https://www.alejandro-colomar.es>\n"},{"id":"554137","messageId":"20261005032348.GA10163@coredump.intra.peff.net","threadId":"66451","inReplyTo":"asCY8kLEV4OAG1BG@debian","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2026-10-05T03:23:48Z","receivedAt":"2026-10-05T03:23:57Z","isPatch":false,"body":"On Sat, Oct 03, 2026 at 07:59:43AM +0200, Alejandro Colomar wrote:\n\n> > I'm not 100% sure, but I think \"git show bisect/bad\" should work.\n> \n> Thanks!  It works.\n> \n> I guess the plumbing version of it would be\n> \tgit rev-list -1 bisect/bad\n> right?\n\nYeah. Or even just \"git rev-parse bisect/bad\" (maybe with --verify if\nappropriate).\n\n-Peff\n"},{"id":"554169","messageId":"asOaBQ_vrF6NC0dW@debian","threadId":"66451","inReplyTo":"20261005032348.GA10163@coredump.intra.peff.net","subject":"Re: git-bisect(1) next after finding the commit","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2026-10-05T12:37:57Z","receivedAt":"2026-10-05T12:38:02Z","isPatch":false,"body":"Hi Jeff,\n\n> Date: 2026-10-04 23:23:48-0400\n> From: Jeff King <peff@peff.net>\n>\n> On Sat, Oct 03, 2026 at 07:59:43AM +0200, Alejandro Colomar wrote:\n> \n> > > I'm not 100% sure, but I think \"git show bisect/bad\" should work.\n> > \n> > Thanks!  It works.\n> > \n> > I guess the plumbing version of it would be\n> > \tgit rev-list -1 bisect/bad\n> > right?\n> \n> Yeah. Or even just \"git rev-parse bisect/bad\" (maybe with --verify if\n> appropriate).\n\nOh, thanks!  I've changed the rev-list -1 calls to do rev-parse.\n\n\nHave a lovely day!\nAlex\n\n> -Peff\n\n-- \n<https://www.alejandro-colomar.es>\n"}]}