{"thread":{"id":"51635","subject":"git grep -F (fixed string) requires matching parenthesis?","startedAt":"2019-08-13T06:01:10Z","lastAt":"2019-08-13T12:33:14Z","messageCount":3,"participants":["nanaya","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"380359","messageId":"35477812-7889-4f32-85ac-d3da4e7ff902@www.fastmail.com","threadId":"51635","inReplyTo":null,"subject":"git grep -F (fixed string) requires matching parenthesis?","fromName":"nanaya","fromEmail":"edho@fastmail.com","sentAt":"2019-08-13T06:01:04Z","receivedAt":"2019-08-13T06:01:10Z","isPatch":false,"sender":{"key":"edho@fastmail.com","avatar":null},"body":"Hi,\n\nI observed this today:\n\n$ git grep -F '('\nfatal: unmatched parenthesis\n\nWhich doesn't make sense and I believe shouldn't happen.\n\n$ git --version\ngit version 2.22.0\n"},{"id":"380365","messageId":"20190813121733.GA10787@sigill.intra.peff.net","threadId":"51635","inReplyTo":"35477812-7889-4f32-85ac-d3da4e7ff902@www.fastmail.com","subject":"Re: git grep -F (fixed string) requires matching parenthesis?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-13T12:17:33Z","receivedAt":"2019-08-13T12:17:36Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 13, 2019 at 03:01:04PM +0900, nanaya wrote:\n\n> I observed this today:\n> \n> $ git grep -F '('\n> fatal: unmatched parenthesis\n> \n> Which doesn't make sense and I believe shouldn't happen.\n\nAt first glance this looks like we're feeding a fixed-string pattern to\nthe regex compiler, which would indeed be a bug.\n\nBut I think it's actually happening at a level above that. git-grep\nsupports multiple patterns, which can be joined with --and, --or, --not,\netc. And they can be grouped with parentheses.\n\nWhat you're seeing is the argument parser thinking your '(' is part of\nthe construction of a boolean match formula, and complaining about the\nlack of closing ')'. You can use \"-e\" to make it clear that it's a\npattern (just as you'd need to for a pattern that starts with \"-\"):\n\n  git grep -F -e '('\n\nSo I think everything is working as designed, though I admit the\nimplication was slightly surprising to me (and note that it only happens\nwith that _specific_ pattern; something like \"(foo\" would not be matched\nby the option parser).\n\n-Peff\n"},{"id":"380378","messageId":"11796f65-42ec-4a0b-b1b1-a693f8eb3cf9@www.fastmail.com","threadId":"51635","inReplyTo":"20190813121733.GA10787@sigill.intra.peff.net","subject":"Re: git grep -F (fixed string) requires matching parenthesis?","fromName":"nanaya","fromEmail":"edho@fastmail.com","sentAt":"2019-08-13T12:33:08Z","receivedAt":"2019-08-13T12:33:14Z","isPatch":false,"sender":{"key":"edho@fastmail.com","avatar":null},"body":"\n\nOn Tue, Aug 13, 2019, at 21:17, Jeff King wrote:\n> But I think it's actually happening at a level above that. git-grep\n> supports multiple patterns, which can be joined with --and, --or, --not,\n> etc. And they can be grouped with parentheses.\n> \n> What you're seeing is the argument parser thinking your '(' is part of\n> the construction of a boolean match formula, and complaining about the\n> lack of closing ')'. You can use \"-e\" to make it clear that it's a\n> pattern (just as you'd need to for a pattern that starts with \"-\"):\n> \n>   git grep -F -e '('\n> \n> So I think everything is working as designed, though I admit the\n> implication was slightly surprising to me (and note that it only happens\n> with that _specific_ pattern; something like \"(foo\" would not be matched\n> by the option parser).\n> \n\nThanks. That was confusing (and the error message didn't help). I've always assumed the grep is similar to posix grep so it was weird the same syntax work for fgrep but not git-grep -F.\n"}]}