{"thread":{"id":"58507","subject":"Scriptable mode for git bisect","startedAt":"2022-09-23T21:03:46Z","lastAt":"2022-09-26T17:38:15Z","messageCount":8,"participants":["Claus Fischer","Đoàn Trần Công Danh","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"463552","messageId":"Yy4c6/jHupgThj7j@clausfischer.com","threadId":"58507","inReplyTo":null,"subject":"Scriptable mode for git bisect","fromName":"Claus Fischer","fromEmail":"claus.fischer@clausfischer.com","sentAt":"2022-09-23T20:54:03Z","receivedAt":"2022-09-23T21:03:46Z","isPatch":false,"sender":{"key":"claus.fischer@clausfischer.com","avatar":null},"body":"\nDear Git maintainers,\n\nI have looked at the manpage of git bisect but have not found\nwhat I need:\nI would like git bisect not just to report the 'bad' revision\nwithin a bunch of text but instead either stop at the first\nbad revision (the last good will then be HEAD~1) or report\nit in a scriptable way, i.e.\n\n  BADHEAD=$(git bisect run --shut-up-and-report-the-bad)\n\nHave I overlooked anything?\n\n***\n\nThe pourpose is to keep the source trees of two different\nprojects that share a few files synchronous.\nMy good/bad-script is a script that checks whether these\nfiles are similar.\nI want git to stop at the first change in source tree A\nso that I can update source tree B with the same commit\nmessage, then proceed to the next change in A that\nchanges one of those files.\n\nRegards,\n\nCluas\n"},{"id":"463562","messageId":"Yy5g80OtVG4op8L1@danh.dev","threadId":"58507","inReplyTo":"Yy4c6/jHupgThj7j@clausfischer.com","subject":"Re: Scriptable mode for git bisect","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-24T01:44:19Z","receivedAt":"2022-09-24T01:44:30Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2022-09-23 22:54:03+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n> \n> Dear Git maintainers,\n> \n> I have looked at the manpage of git bisect but have not found\n> what I need:\n> I would like git bisect not just to report the 'bad' revision\n> within a bunch of text but instead either stop at the first\n> bad revision (the last good will then be HEAD~1) or report\n> it in a scriptable way, i.e.\n> \n>   BADHEAD=$(git bisect run --shut-up-and-report-the-bad)\n> \n> Have I overlooked anything?\n\nAfter running \"git bisect run\"\nYou can take its revisions with:\n\n\tBADHEAD=$(git rev-parse --verify refs/bisect/bad)\n\n> \n> ***\n> \n> The pourpose is to keep the source trees of two different\n> projects that share a few files synchronous.\n> My good/bad-script is a script that checks whether these\n> files are similar.\n> I want git to stop at the first change in source tree A\n> so that I can update source tree B with the same commit\n> message, then proceed to the next change in A that\n> changes one of those files.\n> \n> Regards,\n> \n> Cluas\n\n-- \nDanh\n"},{"id":"463567","messageId":"E10623C2-FF73-4E5B-AD28-C255B02F3B0F@clausfischer.com","threadId":"58507","inReplyTo":"Yy5g80OtVG4op8L1@danh.dev","subject":"Re: Scriptable mode for git bisect","fromName":"Claus Fischer","fromEmail":"claus.fischer@clausfischer.com","sentAt":"2022-09-24T09:32:52Z","receivedAt":"2022-09-24T09:33:02Z","isPatch":false,"sender":{"key":"claus.fischer@clausfischer.com","avatar":null},"body":"I tried that but it turns out it does not always stop at the bad revision.\n\nClaus\n\n> On 24.09.2022, at 03:44, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n> \n> On 2022-09-23 22:54:03+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n>> \n>> Dear Git maintainers,\n>> \n>> I have looked at the manpage of git bisect but have not found\n>> what I need:\n>> I would like git bisect not just to report the 'bad' revision\n>> within a bunch of text but instead either stop at the first\n>> bad revision (the last good will then be HEAD~1) or report\n>> it in a scriptable way, i.e.\n>> \n>>  BADHEAD=$(git bisect run --shut-up-and-report-the-bad)\n>> \n>> Have I overlooked anything?\n> \n> After running \"git bisect run\"\n> You can take its revisions with:\n> \n> \tBADHEAD=$(git rev-parse --verify refs/bisect/bad)\n> \n>> \n>> ***\n>> \n>> The pourpose is to keep the source trees of two different\n>> projects that share a few files synchronous.\n>> My good/bad-script is a script that checks whether these\n>> files are similar.\n>> I want git to stop at the first change in source tree A\n>> so that I can update source tree B with the same commit\n>> message, then proceed to the next change in A that\n>> changes one of those files.\n>> \n>> Regards,\n>> \n>> Cluas\n> \n> -- \n> Danh\n\n"},{"id":"463568","messageId":"Yy7R20yhOjIODpJ6@danh.dev","threadId":"58507","inReplyTo":"E10623C2-FF73-4E5B-AD28-C255B02F3B0F@clausfischer.com","subject":"Re: Scriptable mode for git bisect","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-24T09:46:03Z","receivedAt":"2022-09-24T09:46:12Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2022-09-24 11:32:52+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n> I tried that but it turns out it does not always stop at the bad revision.\n\n\"git bisect\" won't stop at the bad revision, it only left\n\"refs/bisect/bad\" point to the first bad revision, assuming\nnon-alternative terms were used.\n\nIf refs/bisect/bad doesn't point to the first bad revision, your\ninstallation is borked. Please file a bug report.\n\n> \n> Claus\n> \n> > On 24.09.2022, at 03:44, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n> > \n> > On 2022-09-23 22:54:03+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n> >> \n> >> Dear Git maintainers,\n> >> \n> >> I have looked at the manpage of git bisect but have not found\n> >> what I need:\n> >> I would like git bisect not just to report the 'bad' revision\n> >> within a bunch of text but instead either stop at the first\n> >> bad revision (the last good will then be HEAD~1) or report\n> >> it in a scriptable way, i.e.\n> >> \n> >>  BADHEAD=$(git bisect run --shut-up-and-report-the-bad)\n> >> \n> >> Have I overlooked anything?\n> > \n> > After running \"git bisect run\"\n> > You can take its revisions with:\n> > \n> > \tBADHEAD=$(git rev-parse --verify refs/bisect/bad)\n> > \n> >> \n> >> ***\n> >> \n> >> The pourpose is to keep the source trees of two different\n> >> projects that share a few files synchronous.\n> >> My good/bad-script is a script that checks whether these\n> >> files are similar.\n> >> I want git to stop at the first change in source tree A\n> >> so that I can update source tree B with the same commit\n> >> message, then proceed to the next change in A that\n> >> changes one of those files.\n> >> \n> >> Regards,\n> >> \n> >> Cluas\n> > \n> > -- \n> > Danh\n> \n\n-- \nDanh\n"},{"id":"463573","messageId":"xmqqwn9srb9e.fsf@gitster.g","threadId":"58507","inReplyTo":"Yy5g80OtVG4op8L1@danh.dev","subject":"Re: Scriptable mode for git bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-09-24T16:24:29Z","receivedAt":"2022-09-24T16:24:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n> On 2022-09-23 22:54:03+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n>> \n>> Dear Git maintainers,\n>> \n>> I have looked at the manpage of git bisect but have not found\n>> what I need:\n>> I would like git bisect not just to report the 'bad' revision\n>> within a bunch of text but instead either stop at the first\n>> bad revision (the last good will then be HEAD~1) or report\n>> it in a scriptable way, i.e.\n>> \n>>   BADHEAD=$(git bisect run --shut-up-and-report-the-bad)\n>> \n>> Have I overlooked anything?\n>\n> After running \"git bisect run\"\n> You can take its revisions with:\n>\n> \tBADHEAD=$(git rev-parse --verify refs/bisect/bad)\n\nChristian, who invested quite a lot of work in the command (cc'ed),\nmay have more tricks up his sleeve.\n\nYou can also check .git/BISECT_LOG; the value of refs/bisect/bad is\nthe source of truth, as the final verdict message given by the\ncommand (cf. builtin/bisect--helper.c::bisect_successful() that\nreads from \"refs/bisect/$bad\" which is called when \"the first bad\ncommit\" is found by bisect.c::bisect_next_all()).\n\nOne thing that may confuse a new user is that the commit HEAD, when\n\"git bisect\" finds the first bad commit, may not be a bad one.  You\nstart from a longer streatch of history (time flows from left to right,\nB and G are known bad and good ones, ? are not known)\n\n               ?---?---?\n              /         \\\n    -----G---?---?---?---?---?---B\n\nand then go narrowing down by answering \"is this one good?\"\nquestions.  Answering \"Good\" paints all its unknown ancestors as\n\"Good\".  The final step may look like this, where the sole '?' is\nthe commit that is checked out to be tested:\n\n               G---G---G\n              /         \\\n    -----G---G---G---?---B---B---B\n\nAnd the answer to the final step may be \"good\" or \"bad\".  If it is\n\"good\", then the first bad commit would be its child commit, which\nis a merge commit that introduced the badness into the history.\n\nBut still, the first bad commit is found at refs/bisect/bad\n"},{"id":"463592","messageId":"Yy+n7/NolP5rCpwX@danh.dev","threadId":"58507","inReplyTo":"69B998A9-0E3E-45F0-8733-F2A3F11625A5@clausfischer.com","subject":"Re: Scriptable mode for git bisect","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-25T00:59:27Z","receivedAt":"2022-09-25T00:59:40Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2022-09-25 01:46:13+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n> Well since I usually don’t have many revisions backwards, typically\n> no more than 50, I can just traverse the tree backwards from main.\n> I remember the last ‘bad’ revision before the good one.\n> So there’s a solution for me.\n> \n> Yes the bisect command puts the correct ‘first bad’ revision in its\n> output but it’s surrounded by a large amount of useless text. It\n> would be nice to have a ‘quiet’ flag that lets it output just the\n> bad revision. Alternatively, that it ends by checking out just that\n> bad revision before revert.\n> \n> My problem is solved by stepping backwards to HEAD~1 each time, but\n> you might consider making bisect more scriptable.\n\nNo, you don't need to parse \"git bisect\" output to get the \"first bad\"\nrevision. The \"first bad\" revision is stored in refs/bisect/bad.\n\nAnd you can take the \"first bad\" revision in a scriptable way with:\n\n\tFIRST_BAD=$(git rev-parse --verify refs/bisect/bad)\n\nOf course, after finishing bisecting.\n\n-- \nDanh\n"},{"id":"463599","messageId":"C9CD178B-7A21-4F89-9D74-7CBD68DBF0C2@clausfischer.com","threadId":"58507","inReplyTo":"Yy+n7/NolP5rCpwX@danh.dev","subject":"Re: Scriptable mode for git bisect","fromName":"Claus Fischer","fromEmail":"claus.fischer@clausfischer.com","sentAt":"2022-09-25T12:42:43Z","receivedAt":"2022-09-25T12:42:52Z","isPatch":false,"sender":{"key":"claus.fischer@clausfischer.com","avatar":null},"body":"Oh thank you, I didn’t know that / didn’t grasp that while reading (apparently too fast) your previous mails.\n\nThat is way nicer.\n\nThank you.\n\nClaus\n\n> On 25.09.2022, at 02:59, Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n> \n> On 2022-09-25 01:46:13+0200, Claus Fischer <claus.fischer@clausfischer.com> wrote:\n>> Well since I usually don’t have many revisions backwards, typically\n>> no more than 50, I can just traverse the tree backwards from main.\n>> I remember the last ‘bad’ revision before the good one.\n>> So there’s a solution for me.\n>> \n>> Yes the bisect command puts the correct ‘first bad’ revision in its\n>> output but it’s surrounded by a large amount of useless text. It\n>> would be nice to have a ‘quiet’ flag that lets it output just the\n>> bad revision. Alternatively, that it ends by checking out just that\n>> bad revision before revert.\n>> \n>> My problem is solved by stepping backwards to HEAD~1 each time, but\n>> you might consider making bisect more scriptable.\n> \n> No, you don't need to parse \"git bisect\" output to get the \"first bad\"\n> revision. The \"first bad\" revision is stored in refs/bisect/bad.\n> \n> And you can take the \"first bad\" revision in a scriptable way with:\n> \n> \tFIRST_BAD=$(git rev-parse --verify refs/bisect/bad)\n> \n> Of course, after finishing bisecting.\n> \n> -- \n> Danh\n\n"},{"id":"463642","messageId":"xmqqo7v2qdf1.fsf@gitster.g","threadId":"58507","inReplyTo":"C9CD178B-7A21-4F89-9D74-7CBD68DBF0C2@clausfischer.com","subject":"Re: Scriptable mode for git bisect","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-09-26T17:00:02Z","receivedAt":"2022-09-26T17:38:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Claus Fischer <claus.fischer@clausfischer.com> writes:\n\n> Oh thank you, I didn’t know that / didn’t grasp that while reading (apparently too fast) your previous mails.\n>\n> That is way nicer.\n>\n> Thank you.\n>\n> Claus\n\nNow I am puzzled by your earlier response in the thread, e.g.\n\n  https://lore.kernel.org/git/E10623C2-FF73-4E5B-AD28-C255B02F3B0F@clausfischer.com/\n\nIn any case, it is good to see that your issue has been solved.\n\n"}]}