grep: teach --debug option to dump the parse tree
Our "grep" allows complex boolean expressions to be formed to match each individual line with operators like --and, '(', ')' and --not. Introduce the "--debug" option to show the parse tree to help people who want to debug and enhance it. Also "log" learns "--grep-debug" option to do the same. The command line parser to the log family is a lot more limited than the general "git grep" parser, but it has special handling for header matching (e.g. "--author"), and a parse tree is valuable when working on it. Note that "--all-match" is *not* any individual node in the parse tree. It is an instruction to the evaluator to check all the nodes in the top-level backbone have matched and reject a document as non-matching otherwise. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -772,6 +772,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||
"indicate hit with exit status without output"),
|
||||
OPT_BOOLEAN(0, "all-match", &opt.all_match,
|
||||
"show only matches from files that match all patterns"),
|
||||
{ OPTION_SET_INT, 0, "debug", &opt.debug, NULL,
|
||||
"show parse tree for grep expression",
|
||||
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1 },
|
||||
OPT_GROUP(""),
|
||||
{ OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
|
||||
"pager", "show matching files in the pager",
|
||||
|
Reference in New Issue
Block a user