{"thread":{"id":"56033","subject":"[BUG] 'git bisect start' fails to detect bad revisions without '--'","startedAt":"2021-06-30T18:47:22Z","lastAt":"2021-07-28T20:58:21Z","messageCount":2,"participants":["Philippe Blain","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"428850","messageId":"0df90d98-3b79-3751-8712-69e1d44a32fd@gmail.com","threadId":"56033","inReplyTo":null,"subject":"[BUG] 'git bisect start' fails to detect bad revisions without '--'","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2021-06-30T18:47:15Z","receivedAt":"2021-06-30T18:47:22Z","isPatch":false,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hello all,\n\nI've found a small bug in the argument parsing of 'git bisect 'start',\ni.e builtin/bisect--helper.c::bisect_start.\n\nIf one mistypes bad (or good) revisions but does not write the double-dash,\nthe code does not check that the revisions exist and it goes on and checks out HEAD.\n From what I understand the mistyped revisions are (in some cases) interpreted as paths\n(they are written to '.git/BISECT_NAMES), even if they do not match any paths...\n\nFor example, these invocations all check out HEAD and do not give any error in git.git:\n\n\tgit bisect start BAD GOOD\n\tgit bisect start v2.31.0 GOOD\n\tgit bisect start v2.31.0 GOOD ANOTHER\n\nBut these correctly error:\n\n\tgit bisect start BAD GOOD --\n\tgit bisect start v2.31.0 GOOD --\n\tgit bisect start v2.31.0 GOOD ANOTHER --\n\tgit bisect start v2.31.0 v2.30.0 GOOD BAD\n\nThis one does not error and correctly checks out the mid point between 2.31 and 2.30,\nbut does not check that BAD exists (in this case it's not written to BISECT_NAMES):\n\n\tgit bisect start v2.31.0 v2.30.0 BAD\n\n\nThis is on the latest master, 670b81a890 (The second batch, 2021-06-14). I tried older versions\nbefore the start of the conversion of 'git bisect' from shell to C and they seem to behave the same.\n\nI'm CC-ing Christian and Dscho since I noticed 73c6de06af (bisect: don't use invalid oid\nas rev when starting, 2020-09-25) touched the argument parsing in 'bisect start' and is tangentially\nrelated.\n\nCheers,\n\nPhilippe.\n"},{"id":"431435","messageId":"CAP8UFD1pfFwSFMUJ-pR02xNm7kzYwqabPKc1L-jb_rELuZAVqA@mail.gmail.com","threadId":"56033","inReplyTo":"0df90d98-3b79-3751-8712-69e1d44a32fd@gmail.com","subject":"Re: [BUG] 'git bisect start' fails to detect bad revisions without '--'","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2021-07-28T20:58:05Z","receivedAt":"2021-07-28T20:58:21Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi Philippe,\n\nOn Wed, Jun 30, 2021 at 8:47 PM Philippe Blain\n<levraiphilippeblain@gmail.com> wrote:\n>\n> Hello all,\n>\n> I've found a small bug in the argument parsing of 'git bisect 'start',\n> i.e builtin/bisect--helper.c::bisect_start.\n\nSorry for the late reply to this, and thanks for the report!\n\n> If one mistypes bad (or good) revisions but does not write the double-dash,\n> the code does not check that the revisions exist and it goes on and checks out HEAD.\n>  From what I understand the mistyped revisions are (in some cases) interpreted as paths\n> (they are written to '.git/BISECT_NAMES), even if they do not match any paths...\n>\n> For example, these invocations all check out HEAD and do not give any error in git.git:\n>\n>         git bisect start BAD GOOD\n>         git bisect start v2.31.0 GOOD\n>         git bisect start v2.31.0 GOOD ANOTHER\n>\n> But these correctly error:\n>\n>         git bisect start BAD GOOD --\n>         git bisect start v2.31.0 GOOD --\n>         git bisect start v2.31.0 GOOD ANOTHER --\n>         git bisect start v2.31.0 v2.30.0 GOOD BAD\n>\n> This one does not error and correctly checks out the mid point between 2.31 and 2.30,\n> but does not check that BAD exists (in this case it's not written to BISECT_NAMES):\n>\n>         git bisect start v2.31.0 v2.30.0 BAD\n>\n> This is on the latest master, 670b81a890 (The second batch, 2021-06-14). I tried older versions\n> before the start of the conversion of 'git bisect' from shell to C and they seem to behave the same.\n\nYeah, I agree that it looks like the behavior could be improved. It\ncould be tricky though, as, even if something does not match any paths\nin the current commit nor in the BAD and GOOD commits, it could\nperhaps match a path that is in one of the in-between commits.\n\nBest,\nChristian.\n"}]}