{"thread":{"id":"42485","subject":"Fatal bug on revert with --author","startedAt":"2016-05-30T14:16:50Z","lastAt":"2016-05-30T18:55:29Z","messageCount":2,"participants":["Andreas Lutro","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"287819","messageId":"CAKYJjwgkH5gtQHsV_=4O0SGqb6GEXWC=rdFWO9Jv36dL-NaPcw@mail.gmail.com","threadId":"42485","inReplyTo":null,"subject":"Fatal bug on revert with --author","fromName":"Andreas Lutro","fromEmail":"anlutro@gmail.com","sentAt":"2016-05-30T14:16:50Z","receivedAt":"2016-05-30T14:16:50Z","isPatch":false,"sender":{"key":"anlutro@gmail.com","avatar":null},"body":"So I learned today that --author is not a supported argument to git\nrevert. It took me a long time to realize this, though, because the\nerror I got was very cryptic:\n\n  fatal: BUG: expected exactly one commit from walk\n\nHere's a very simple reproducible case:\nhttps://gist.github.com/anlutro/67e0cec1a6a419e6d44131b0bc1deff6\n\nI was recommended to send this report here by #git on irc.freenode.net.\n\nThanks,\nAndreas\n"},{"id":"287847","messageId":"20160530185529.GA18074@sigill.intra.peff.net","threadId":"42485","inReplyTo":"CAKYJjwgkH5gtQHsV_=4O0SGqb6GEXWC=rdFWO9Jv36dL-NaPcw@mail.gmail.com","subject":"Re: Fatal bug on revert with --author","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-05-30T18:55:29Z","receivedAt":"2016-05-30T18:55:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 30, 2016 at 04:16:50PM +0200, Andreas Lutro wrote:\n\n> So I learned today that --author is not a supported argument to git\n> revert. It took me a long time to realize this, though, because the\n> error I got was very cryptic:\n> \n>   fatal: BUG: expected exactly one commit from walk\n> \n> Here's a very simple reproducible case:\n> https://gist.github.com/anlutro/67e0cec1a6a419e6d44131b0bc1deff6\n> \n> I was recommended to send this report here by #git on irc.freenode.net.\n\nHmm. It _is_ a supported command-line argument, as you can pass\narbitrary revision options to revert. So:\n\n  git revert --author peff HEAD\n\nshould revert all of my commits (whether that is _useful_, I am not\nsure, but it is a consequence of the fact that revert simply passes its\narguments to the regular revision machinery).\n\nBut in your example, you pass the author \"test\", which matches nothing.\nAnd so we end up with nothing to revert. But rather than saying so, we\nfall into a backwards-compatibility code path:\n\n        /*\n         * If we were called as \"git cherry-pick <commit>\", just\n         * cherry-pick/revert it, set CHERRY_PICK_HEAD /\n         * REVERT_HEAD, and don't touch the sequencer state.\n         * This means it is possible to cherry-pick in the middle\n         * of a cherry-pick sequence.\n         */\n        if (opts->revs->cmdline.nr == 1 &&\n            opts->revs->cmdline.rev->whence == REV_CMD_REV &&\n            opts->revs->no_walk &&\n            !opts->revs->cmdline.rev->flags) {\n                struct commit *cmit;\n                if (prepare_revision_walk(opts->revs))\n                        die(_(\"revision walk setup failed\"));\n                cmit = get_revision(opts->revs);\n                if (!cmit || get_revision(opts->revs))\n                        die(\"BUG: expected exactly one commit from walk\");\n                return single_pick(cmit, opts);\n        }\n\nI think this conditional should not be triggering, because even though\nwe did receive a single argument, we _also_ got options which imply that\nthe user expected us to walk and find other commits.\n\n-Peff\n"}]}