{"thread":{"id":"31777","subject":"[PATCH v2 0/7] Tying loose ends on grep-pcre","startedAt":"2012-10-10T07:55:07Z","lastAt":"2012-10-11T07:08:35Z","messageCount":11,"participants":["Junio C Hamano","Michael Haggerty"],"isPatch":true,"patchVersion":2,"patchTotal":7},"messages":[{"id":"200884","messageId":"1349855714-17008-1-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":null,"subject":"[PATCH v2 0/7] Tying loose ends on grep-pcre","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:07Z","receivedAt":"2012-10-10T07:55:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It took longer than expected, but here is a reroll of the previous\nseries to bring more recent \"git grep\" enhancements to the \"--grep\"\noption of commands in \"git log\" family.\n\nThe early part of the series (1-3) refactors the code that reads\nconfiguration items related to \"grep\" and the code that mixes the\nresult with the command line options to prepare grep_opt, which so\nfar lived in builtin/grep.c, and moves them to the grep.[ch] at the\ntop-level.\n\nThe middle part (4-6) reuses the code to set-up grep_opt refactored\nby the earlier part of the series on revs->grep_filter that is used\nin \"git log --grep=...\" processing.  It incidentally fixes a small\nbug where \"git log -F -E --grep='<ere>'\" did not look for matches to\nthe pattern in extended regular expression, and adds --basic-regexp\nand --perl-regexp command line options to \"git log\" family for\ncompleteness.\n\nThe last one teaches \"git log\" family to honor the \"grep.*\"\nconfiguration variables, e.g. \"grep.patterntype\", so that you can\nsay \"git -c grep.patterntype=perl log --grep='(?:pcre)'\".\n\nObviously, it is too late for this cycle and will not graduate to\n'master' before the 1.8.0 final.\n\n\nJunio C Hamano (7):\n  builtin/grep.c: make configuration callback more reusable\n  grep: move the configuration parsing logic to grep.[ch]\n  grep: move pattern-type bits support to top-level grep.[ch]\n  revisions: initialize revs->grep_filter using grep_init()\n  log --grep: use the same helper to set -E/-F options as \"git grep\"\n  log --grep: accept --basic-regexp and --perl-regexp\n  log: honor grep.* configuration\n\n Documentation/rev-list-options.txt |  10 +++\n builtin/grep.c                     | 133 ++--------------------------\n builtin/log.c                      |   8 +-\n grep.c                             | 177 +++++++++++++++++++++++++++++++++++++\n grep.h                             |   6 ++\n revision.c                         |  14 ++-\n t/t4202-log.sh                     |   6 ++\n 7 files changed, 225 insertions(+), 129 deletions(-)\n\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200885","messageId":"1349855714-17008-2-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 1/7] builtin/grep.c: make configuration callback more reusable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:08Z","receivedAt":"2012-10-10T07:55:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The grep_config() function takes one instance of grep_opt as its\ncallback parameter, and populates it by running git_config().\n\nThis has three practical implications:\n\n - You have to have an instance of grep_opt already when you call\n   the configuration, but that is not necessarily always true.  You\n   may be trying to initialize the grep_filter member of rev_info,\n   but are not ready to call init_revisions() on it yet.\n\n - It is not easy to enhance grep_config() in such a way to make it\n   cascade to other callback functions to grab other variables in\n   one call of git_config(); grep_config() can be cascaded into from\n   other callbacks, but it has to be at the leaf level of a cascade.\n\n - If you ever need to use more than one instance of grep_opt, you\n   will have to open and read the configuration file(s) every time\n   you initialize them.\n\nRearrange the configuration mechanism and model it after how diff\nconfiguration variables are handled.  An early call to git_config()\nreads and remembers the values taken from the configuration in the\ndefault \"template\", and a separate call to grep_init() uses this\ntemplate to instantiate a grep_opt.\n\nThe next step will be to move some of this out of this file so that\nthe other user of the grep machinery (i.e. \"log\") can use it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/grep.c | 104 +++++++++++++++++++++++++++++++++++++++++++--------------\n 1 file changed, 79 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 82530a6..83232c9 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -308,9 +308,41 @@ static void grep_pattern_type_options(const int pattern_type, struct grep_opt *o\n \t}\n }\n \n+static struct grep_opt grep_defaults;\n+\n+/*\n+ * Initialize the grep_defaults template with hardcoded defaults.\n+ * We could let the compiler do this, but without C99 initializers\n+ * the code gets unwieldy and unreadable, so...\n+ */\n+static void init_grep_defaults(void)\n+{\n+\tstruct grep_opt *opt = &grep_defaults;\n+\n+\tmemset(opt, 0, sizeof(*opt));\n+\topt->relative = 1;\n+\topt->pathname = 1;\n+\topt->regflags = REG_NEWLINE;\n+\topt->max_depth = -1;\n+\topt->pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED;\n+\topt->extended_regexp_option = 0;\n+\tstrcpy(opt->color_context, \"\");\n+\tstrcpy(opt->color_filename, \"\");\n+\tstrcpy(opt->color_function, \"\");\n+\tstrcpy(opt->color_lineno, \"\");\n+\tstrcpy(opt->color_match, GIT_COLOR_BOLD_RED);\n+\tstrcpy(opt->color_selected, \"\");\n+\tstrcpy(opt->color_sep, GIT_COLOR_CYAN);\n+\topt->color = -1;\n+}\n+\n+/*\n+ * Read the configuration file once and store it in\n+ * the grep_defaults template.\n+ */\n static int grep_config(const char *var, const char *value, void *cb)\n {\n-\tstruct grep_opt *opt = cb;\n+\tstruct grep_opt *opt = &grep_defaults;\n \tchar *color = NULL;\n \n \tif (userdiff_config(var, value) < 0)\n@@ -327,7 +359,7 @@ static int grep_config(const char *var, const char *value, void *cb)\n \tif (!strcmp(var, \"grep.patterntype\")) {\n \t\topt->pattern_type_option = parse_pattern_type_arg(var, value);\n \t\treturn 0;\n-  }\n+\t}\n \n \tif (!strcmp(var, \"grep.linenumber\")) {\n \t\topt->linenum = git_config_bool(var, value);\n@@ -350,8 +382,7 @@ static int grep_config(const char *var, const char *value, void *cb)\n \t\tcolor = opt->color_selected;\n \telse if (!strcmp(var, \"color.grep.separator\"))\n \t\tcolor = opt->color_sep;\n-\telse\n-\t\treturn git_color_default_config(var, value, cb);\n+\n \tif (color) {\n \t\tif (!value)\n \t\t\treturn config_error_nonbool(var);\n@@ -360,6 +391,47 @@ static int grep_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n \n+/*\n+ * Initialize one instance of grep_opt and copy the\n+ * default values from the template we read the configuration\n+ * information in an earlier call to git_config(grep_config).\n+ */\n+static void grep_init(struct grep_opt *opt, const char *prefix)\n+{\n+\tstruct grep_opt *def = &grep_defaults;\n+\n+\tmemset(opt, 0, sizeof(*opt));\n+\topt->prefix = prefix;\n+\topt->prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n+\topt->pattern_tail = &opt->pattern_list;\n+\topt->header_tail = &opt->header_list;\n+\n+\topt->color = def->color;\n+\topt->extended_regexp_option = def->extended_regexp_option;\n+\topt->pattern_type_option = def->pattern_type_option;\n+\topt->linenum = def->linenum;\n+\topt->max_depth = def->max_depth;\n+\topt->pathname = def->pathname;\n+\topt->regflags = def->regflags;\n+\topt->relative = def->relative;\n+\n+\tstrcpy(opt->color_context, def->color_context);\n+\tstrcpy(opt->color_filename, def->color_filename);\n+\tstrcpy(opt->color_function, def->color_function);\n+\tstrcpy(opt->color_lineno, def->color_lineno);\n+\tstrcpy(opt->color_match, def->color_match);\n+\tstrcpy(opt->color_selected, def->color_selected);\n+\tstrcpy(opt->color_sep, def->color_sep);\n+}\n+\n+static int grep_cmd_config(const char *var, const char *value, void *cb)\n+{\n+\tint st = grep_config(var, value, cb);\n+\tif (git_color_default_config(var, value, cb) < 0)\n+\t\tst = -1;\n+\treturn st;\n+}\n+\n static void *lock_and_read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size)\n {\n \tvoid *data;\n@@ -839,27 +911,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage_with_options(grep_usage, options);\n \n-\tmemset(&opt, 0, sizeof(opt));\n-\topt.prefix = prefix;\n-\topt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n-\topt.relative = 1;\n-\topt.pathname = 1;\n-\topt.pattern_tail = &opt.pattern_list;\n-\topt.header_tail = &opt.header_list;\n-\topt.regflags = REG_NEWLINE;\n-\topt.max_depth = -1;\n-\topt.pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED;\n-\topt.extended_regexp_option = 0;\n-\n-\tstrcpy(opt.color_context, \"\");\n-\tstrcpy(opt.color_filename, \"\");\n-\tstrcpy(opt.color_function, \"\");\n-\tstrcpy(opt.color_lineno, \"\");\n-\tstrcpy(opt.color_match, GIT_COLOR_BOLD_RED);\n-\tstrcpy(opt.color_selected, \"\");\n-\tstrcpy(opt.color_sep, GIT_COLOR_CYAN);\n-\topt.color = -1;\n-\tgit_config(grep_config, &opt);\n+\tinit_grep_defaults();\n+\tgit_config(grep_cmd_config, NULL);\n+\tgrep_init(&opt, prefix);\n \n \t/*\n \t * If there is no -- then the paths must exist in the working\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200886","messageId":"1349855714-17008-3-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 2/7] grep: move the configuration parsing logic to grep.[ch]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:09Z","receivedAt":"2012-10-10T07:55:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The configuration handling is a library-ish part of this program,\nthat is not specific to \"git grep\" command.  It should be reusable\nby \"log\" and others.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/grep.c | 131 ---------------------------------------------------------\n grep.c         | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n grep.h         |   4 ++\n 3 files changed, 134 insertions(+), 131 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 83232c9..b63a9f8 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -261,21 +261,6 @@ static int wait_all(void)\n }\n #endif\n \n-static int parse_pattern_type_arg(const char *opt, const char *arg)\n-{\n-\tif (!strcmp(arg, \"default\"))\n-\t\treturn GREP_PATTERN_TYPE_UNSPECIFIED;\n-\telse if (!strcmp(arg, \"basic\"))\n-\t\treturn GREP_PATTERN_TYPE_BRE;\n-\telse if (!strcmp(arg, \"extended\"))\n-\t\treturn GREP_PATTERN_TYPE_ERE;\n-\telse if (!strcmp(arg, \"fixed\"))\n-\t\treturn GREP_PATTERN_TYPE_FIXED;\n-\telse if (!strcmp(arg, \"perl\"))\n-\t\treturn GREP_PATTERN_TYPE_PCRE;\n-\tdie(\"bad %s argument: %s\", opt, arg);\n-}\n-\n static void grep_pattern_type_options(const int pattern_type, struct grep_opt *opt)\n {\n \tswitch (pattern_type) {\n@@ -308,122 +293,6 @@ static void grep_pattern_type_options(const int pattern_type, struct grep_opt *o\n \t}\n }\n \n-static struct grep_opt grep_defaults;\n-\n-/*\n- * Initialize the grep_defaults template with hardcoded defaults.\n- * We could let the compiler do this, but without C99 initializers\n- * the code gets unwieldy and unreadable, so...\n- */\n-static void init_grep_defaults(void)\n-{\n-\tstruct grep_opt *opt = &grep_defaults;\n-\n-\tmemset(opt, 0, sizeof(*opt));\n-\topt->relative = 1;\n-\topt->pathname = 1;\n-\topt->regflags = REG_NEWLINE;\n-\topt->max_depth = -1;\n-\topt->pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED;\n-\topt->extended_regexp_option = 0;\n-\tstrcpy(opt->color_context, \"\");\n-\tstrcpy(opt->color_filename, \"\");\n-\tstrcpy(opt->color_function, \"\");\n-\tstrcpy(opt->color_lineno, \"\");\n-\tstrcpy(opt->color_match, GIT_COLOR_BOLD_RED);\n-\tstrcpy(opt->color_selected, \"\");\n-\tstrcpy(opt->color_sep, GIT_COLOR_CYAN);\n-\topt->color = -1;\n-}\n-\n-/*\n- * Read the configuration file once and store it in\n- * the grep_defaults template.\n- */\n-static int grep_config(const char *var, const char *value, void *cb)\n-{\n-\tstruct grep_opt *opt = &grep_defaults;\n-\tchar *color = NULL;\n-\n-\tif (userdiff_config(var, value) < 0)\n-\t\treturn -1;\n-\n-\tif (!strcmp(var, \"grep.extendedregexp\")) {\n-\t\tif (git_config_bool(var, value))\n-\t\t\topt->extended_regexp_option = 1;\n-\t\telse\n-\t\t\topt->extended_regexp_option = 0;\n-\t\treturn 0;\n-\t}\n-\n-\tif (!strcmp(var, \"grep.patterntype\")) {\n-\t\topt->pattern_type_option = parse_pattern_type_arg(var, value);\n-\t\treturn 0;\n-\t}\n-\n-\tif (!strcmp(var, \"grep.linenumber\")) {\n-\t\topt->linenum = git_config_bool(var, value);\n-\t\treturn 0;\n-\t}\n-\n-\tif (!strcmp(var, \"color.grep\"))\n-\t\topt->color = git_config_colorbool(var, value);\n-\telse if (!strcmp(var, \"color.grep.context\"))\n-\t\tcolor = opt->color_context;\n-\telse if (!strcmp(var, \"color.grep.filename\"))\n-\t\tcolor = opt->color_filename;\n-\telse if (!strcmp(var, \"color.grep.function\"))\n-\t\tcolor = opt->color_function;\n-\telse if (!strcmp(var, \"color.grep.linenumber\"))\n-\t\tcolor = opt->color_lineno;\n-\telse if (!strcmp(var, \"color.grep.match\"))\n-\t\tcolor = opt->color_match;\n-\telse if (!strcmp(var, \"color.grep.selected\"))\n-\t\tcolor = opt->color_selected;\n-\telse if (!strcmp(var, \"color.grep.separator\"))\n-\t\tcolor = opt->color_sep;\n-\n-\tif (color) {\n-\t\tif (!value)\n-\t\t\treturn config_error_nonbool(var);\n-\t\tcolor_parse(value, var, color);\n-\t}\n-\treturn 0;\n-}\n-\n-/*\n- * Initialize one instance of grep_opt and copy the\n- * default values from the template we read the configuration\n- * information in an earlier call to git_config(grep_config).\n- */\n-static void grep_init(struct grep_opt *opt, const char *prefix)\n-{\n-\tstruct grep_opt *def = &grep_defaults;\n-\n-\tmemset(opt, 0, sizeof(*opt));\n-\topt->prefix = prefix;\n-\topt->prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n-\topt->pattern_tail = &opt->pattern_list;\n-\topt->header_tail = &opt->header_list;\n-\n-\topt->color = def->color;\n-\topt->extended_regexp_option = def->extended_regexp_option;\n-\topt->pattern_type_option = def->pattern_type_option;\n-\topt->linenum = def->linenum;\n-\topt->max_depth = def->max_depth;\n-\topt->pathname = def->pathname;\n-\topt->regflags = def->regflags;\n-\topt->relative = def->relative;\n-\n-\tstrcpy(opt->color_context, def->color_context);\n-\tstrcpy(opt->color_filename, def->color_filename);\n-\tstrcpy(opt->color_function, def->color_function);\n-\tstrcpy(opt->color_lineno, def->color_lineno);\n-\tstrcpy(opt->color_match, def->color_match);\n-\tstrcpy(opt->color_selected, def->color_selected);\n-\tstrcpy(opt->color_sep, def->color_sep);\n-}\n-\n static int grep_cmd_config(const char *var, const char *value, void *cb)\n {\n \tint st = grep_config(var, value, cb);\ndiff --git a/grep.c b/grep.c\nindex edc7776..621e6ec 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -6,6 +6,136 @@\n static int grep_source_load(struct grep_source *gs);\n static int grep_source_is_binary(struct grep_source *gs);\n \n+static struct grep_opt grep_defaults;\n+\n+/*\n+ * Initialize the grep_defaults template with hardcoded defaults.\n+ * We could let the compiler do this, but without C99 initializers\n+ * the code gets unwieldy and unreadable, so...\n+ */\n+void init_grep_defaults(void)\n+{\n+\tstruct grep_opt *opt = &grep_defaults;\n+\n+\tmemset(opt, 0, sizeof(*opt));\n+\topt->relative = 1;\n+\topt->pathname = 1;\n+\topt->regflags = REG_NEWLINE;\n+\topt->max_depth = -1;\n+\topt->pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED;\n+\topt->extended_regexp_option = 0;\n+\tstrcpy(opt->color_context, \"\");\n+\tstrcpy(opt->color_filename, \"\");\n+\tstrcpy(opt->color_function, \"\");\n+\tstrcpy(opt->color_lineno, \"\");\n+\tstrcpy(opt->color_match, GIT_COLOR_BOLD_RED);\n+\tstrcpy(opt->color_selected, \"\");\n+\tstrcpy(opt->color_sep, GIT_COLOR_CYAN);\n+\topt->color = -1;\n+}\n+\n+static int parse_pattern_type_arg(const char *opt, const char *arg)\n+{\n+\tif (!strcmp(arg, \"default\"))\n+\t\treturn GREP_PATTERN_TYPE_UNSPECIFIED;\n+\telse if (!strcmp(arg, \"basic\"))\n+\t\treturn GREP_PATTERN_TYPE_BRE;\n+\telse if (!strcmp(arg, \"extended\"))\n+\t\treturn GREP_PATTERN_TYPE_ERE;\n+\telse if (!strcmp(arg, \"fixed\"))\n+\t\treturn GREP_PATTERN_TYPE_FIXED;\n+\telse if (!strcmp(arg, \"perl\"))\n+\t\treturn GREP_PATTERN_TYPE_PCRE;\n+\tdie(\"bad %s argument: %s\", opt, arg);\n+}\n+\n+/*\n+ * Read the configuration file once and store it in\n+ * the grep_defaults template.\n+ */\n+int grep_config(const char *var, const char *value, void *cb)\n+{\n+\tstruct grep_opt *opt = &grep_defaults;\n+\tchar *color = NULL;\n+\n+\tif (userdiff_config(var, value) < 0)\n+\t\treturn -1;\n+\n+\tif (!strcmp(var, \"grep.extendedregexp\")) {\n+\t\tif (git_config_bool(var, value))\n+\t\t\topt->extended_regexp_option = 1;\n+\t\telse\n+\t\t\topt->extended_regexp_option = 0;\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"grep.patterntype\")) {\n+\t\topt->pattern_type_option = parse_pattern_type_arg(var, value);\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"grep.linenumber\")) {\n+\t\topt->linenum = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"color.grep\"))\n+\t\topt->color = git_config_colorbool(var, value);\n+\telse if (!strcmp(var, \"color.grep.context\"))\n+\t\tcolor = opt->color_context;\n+\telse if (!strcmp(var, \"color.grep.filename\"))\n+\t\tcolor = opt->color_filename;\n+\telse if (!strcmp(var, \"color.grep.function\"))\n+\t\tcolor = opt->color_function;\n+\telse if (!strcmp(var, \"color.grep.linenumber\"))\n+\t\tcolor = opt->color_lineno;\n+\telse if (!strcmp(var, \"color.grep.match\"))\n+\t\tcolor = opt->color_match;\n+\telse if (!strcmp(var, \"color.grep.selected\"))\n+\t\tcolor = opt->color_selected;\n+\telse if (!strcmp(var, \"color.grep.separator\"))\n+\t\tcolor = opt->color_sep;\n+\n+\tif (color) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tcolor_parse(value, var, color);\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+ * Initialize one instance of grep_opt and copy the\n+ * default values from the template we read the configuration\n+ * information in an earlier call to git_config(grep_config).\n+ */\n+void grep_init(struct grep_opt *opt, const char *prefix)\n+{\n+\tstruct grep_opt *def = &grep_defaults;\n+\n+\tmemset(opt, 0, sizeof(*opt));\n+\topt->prefix = prefix;\n+\topt->prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;\n+\topt->pattern_tail = &opt->pattern_list;\n+\topt->header_tail = &opt->header_list;\n+\n+\topt->color = def->color;\n+\topt->extended_regexp_option = def->extended_regexp_option;\n+\topt->pattern_type_option = def->pattern_type_option;\n+\topt->linenum = def->linenum;\n+\topt->max_depth = def->max_depth;\n+\topt->pathname = def->pathname;\n+\topt->regflags = def->regflags;\n+\topt->relative = def->relative;\n+\n+\tstrcpy(opt->color_context, def->color_context);\n+\tstrcpy(opt->color_filename, def->color_filename);\n+\tstrcpy(opt->color_function, def->color_function);\n+\tstrcpy(opt->color_lineno, def->color_lineno);\n+\tstrcpy(opt->color_match, def->color_match);\n+\tstrcpy(opt->color_selected, def->color_selected);\n+\tstrcpy(opt->color_sep, def->color_sep);\n+}\n \n static struct grep_pat *create_grep_pat(const char *pat, size_t patlen,\n \t\t\t\t\tconst char *origin, int no,\ndiff --git a/grep.h b/grep.h\nindex c256ac6..9aa1cc7 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -138,6 +138,10 @@ struct grep_opt {\n \tvoid *output_priv;\n };\n \n+extern void init_grep_defaults(void);\n+extern int grep_config(const char *var, const char *value, void *);\n+extern void grep_init(struct grep_opt *, const char *prefix);\n+\n extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);\n extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);\n extern void append_header_grep_pattern(struct grep_opt *, enum grep_header_field, const char *);\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200887","messageId":"1349855714-17008-4-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 3/7] grep: move pattern-type bits support to top-level grep.[ch]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:10Z","receivedAt":"2012-10-10T07:55:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Switching between -E/-G/-P/-F correctly needs a lot more than just\nflipping opt->regflags bit these days, and we have a nice helper\nfunction buried in builtin/grep.c for the sole use of \"git grep\".\n\nExtract it so that \"log --grep\" family can also use it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/grep.c | 40 +---------------------------------------\n grep.c         | 42 ++++++++++++++++++++++++++++++++++++++++++\n grep.h         |  2 ++\n 3 files changed, 45 insertions(+), 39 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex b63a9f8..c296e6f 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -261,38 +261,6 @@ static int wait_all(void)\n }\n #endif\n \n-static void grep_pattern_type_options(const int pattern_type, struct grep_opt *opt)\n-{\n-\tswitch (pattern_type) {\n-\tcase GREP_PATTERN_TYPE_UNSPECIFIED:\n-\t\t/* fall through */\n-\n-\tcase GREP_PATTERN_TYPE_BRE:\n-\t\topt->fixed = 0;\n-\t\topt->pcre = 0;\n-\t\topt->regflags &= ~REG_EXTENDED;\n-\t\tbreak;\n-\n-\tcase GREP_PATTERN_TYPE_ERE:\n-\t\topt->fixed = 0;\n-\t\topt->pcre = 0;\n-\t\topt->regflags |= REG_EXTENDED;\n-\t\tbreak;\n-\n-\tcase GREP_PATTERN_TYPE_FIXED:\n-\t\topt->fixed = 1;\n-\t\topt->pcre = 0;\n-\t\topt->regflags &= ~REG_EXTENDED;\n-\t\tbreak;\n-\n-\tcase GREP_PATTERN_TYPE_PCRE:\n-\t\topt->fixed = 0;\n-\t\topt->pcre = 1;\n-\t\topt->regflags &= ~REG_EXTENDED;\n-\t\tbreak;\n-\t}\n-}\n-\n static int grep_cmd_config(const char *var, const char *value, void *cb)\n {\n \tint st = grep_config(var, value, cb);\n@@ -798,13 +766,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\t     PARSE_OPT_KEEP_DASHDASH |\n \t\t\t     PARSE_OPT_STOP_AT_NON_OPTION |\n \t\t\t     PARSE_OPT_NO_INTERNAL_HELP);\n-\n-\tif (pattern_type_arg != GREP_PATTERN_TYPE_UNSPECIFIED)\n-\t\tgrep_pattern_type_options(pattern_type_arg, &opt);\n-\telse if (opt.pattern_type_option != GREP_PATTERN_TYPE_UNSPECIFIED)\n-\t\tgrep_pattern_type_options(opt.pattern_type_option, &opt);\n-\telse if (opt.extended_regexp_option)\n-\t\tgrep_pattern_type_options(GREP_PATTERN_TYPE_ERE, &opt);\n+\tgrep_commit_pattern_type(pattern_type_arg, &opt);\n \n \tif (use_index && !startup_info->have_repository)\n \t\t/* die the same way as if we did it at the beginning */\ndiff --git a/grep.c b/grep.c\nindex 621e6ec..279a559 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -137,6 +137,48 @@ void grep_init(struct grep_opt *opt, const char *prefix)\n \tstrcpy(opt->color_sep, def->color_sep);\n }\n \n+void grep_commit_pattern_type(enum grep_pattern_type pattern_type, struct grep_opt *opt)\n+{\n+\tif (pattern_type != GREP_PATTERN_TYPE_UNSPECIFIED)\n+\t\tgrep_set_pattern_type_option(pattern_type, opt);\n+\telse if (opt->pattern_type_option != GREP_PATTERN_TYPE_UNSPECIFIED)\n+\t\tgrep_set_pattern_type_option(opt->pattern_type_option, opt);\n+\telse if (opt->extended_regexp_option)\n+\t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, opt);\n+}\n+\n+void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, struct grep_opt *opt)\n+{\n+\tswitch (pattern_type) {\n+\tcase GREP_PATTERN_TYPE_UNSPECIFIED:\n+\t\t/* fall through */\n+\n+\tcase GREP_PATTERN_TYPE_BRE:\n+\t\topt->fixed = 0;\n+\t\topt->pcre = 0;\n+\t\topt->regflags &= ~REG_EXTENDED;\n+\t\tbreak;\n+\n+\tcase GREP_PATTERN_TYPE_ERE:\n+\t\topt->fixed = 0;\n+\t\topt->pcre = 0;\n+\t\topt->regflags |= REG_EXTENDED;\n+\t\tbreak;\n+\n+\tcase GREP_PATTERN_TYPE_FIXED:\n+\t\topt->fixed = 1;\n+\t\topt->pcre = 0;\n+\t\topt->regflags &= ~REG_EXTENDED;\n+\t\tbreak;\n+\n+\tcase GREP_PATTERN_TYPE_PCRE:\n+\t\topt->fixed = 0;\n+\t\topt->pcre = 1;\n+\t\topt->regflags &= ~REG_EXTENDED;\n+\t\tbreak;\n+\t}\n+}\n+\n static struct grep_pat *create_grep_pat(const char *pat, size_t patlen,\n \t\t\t\t\tconst char *origin, int no,\n \t\t\t\t\tenum grep_pat_token t,\ndiff --git a/grep.h b/grep.h\nindex 9aa1cc7..701c784 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -141,6 +141,8 @@ struct grep_opt {\n extern void init_grep_defaults(void);\n extern int grep_config(const char *var, const char *value, void *);\n extern void grep_init(struct grep_opt *, const char *prefix);\n+void grep_set_pattern_type_option(enum grep_pattern_type, struct grep_opt *opt);\n+void grep_commit_pattern_type(enum grep_pattern_type, struct grep_opt *opt);\n \n extern void append_grep_pat(struct grep_opt *opt, const char *pat, size_t patlen, const char *origin, int no, enum grep_pat_token t);\n extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200888","messageId":"1349855714-17008-5-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 4/7] revisions: initialize revs->grep_filter using grep_init()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:11Z","receivedAt":"2012-10-10T07:55:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Instead of using the hand-rolled initialization sequence,\nuse grep_init() to populate the necessary bits.  This opens\nthe door to allow the calling commands to optionally read\ngrep.* configuration variables via git_config() if they\nwant to.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n grep.c     | 5 +++++\n revision.c | 6 ++++--\n 2 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 279a559..a947a68 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -16,6 +16,11 @@ static struct grep_opt grep_defaults;\n void init_grep_defaults(void)\n {\n \tstruct grep_opt *opt = &grep_defaults;\n+\tstatic int run_once;\n+\n+\tif (run_once)\n+\t\treturn;\n+\trun_once++;\n \n \tmemset(opt, 0, sizeof(*opt));\n \topt->relative = 1;\ndiff --git a/revision.c b/revision.c\nindex a09e60b..a4a9314 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1048,9 +1048,9 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \n \trevs->commit_format = CMIT_FMT_DEFAULT;\n \n+\tinit_grep_defaults();\n+\tgrep_init(&revs->grep_filter, prefix);\n \trevs->grep_filter.status_only = 1;\n-\trevs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);\n-\trevs->grep_filter.header_tail = &(revs->grep_filter.header_list);\n \trevs->grep_filter.regflags = REG_NEWLINE;\n \n \tdiff_setup(&revs->diffopt);\n@@ -1893,6 +1893,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s\n \trevs->diffopt.abbrev = revs->abbrev;\n \tdiff_setup_done(&revs->diffopt);\n \n+\tgrep_commit_pattern_type(GREP_PATTERN_TYPE_UNSPECIFIED,\n+\t\t\t\t &revs->grep_filter);\n \tcompile_grep_patterns(&revs->grep_filter);\n \n \tif (revs->reverse && revs->reflog_info)\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200889","messageId":"1349855714-17008-6-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 5/7] log --grep: use the same helper to set -E/-F options as \"git grep\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:12Z","receivedAt":"2012-10-10T07:55:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The command line option parser for \"git log -F -E --grep='<ere>'\"\ndid not flip the \"fixed\" bit, violating the general \"last option\nwins\" principle among conflicting options.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n revision.c     | 4 ++--\n t/t4202-log.sh | 6 ++++++\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex a4a9314..68545c8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--grep-debug\")) {\n \t\trevs->grep_filter.debug = 1;\n \t} else if (!strcmp(arg, \"--extended-regexp\") || !strcmp(arg, \"-E\")) {\n-\t\trevs->grep_filter.regflags |= REG_EXTENDED;\n+\t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n \t\trevs->grep_filter.regflags |= REG_ICASE;\n \t\tDIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n-\t\trevs->grep_filter.fixed = 1;\n+\t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);\n \t} else if (!strcmp(arg, \"--all-match\")) {\n \t\trevs->grep_filter.all_match = 1;\n \t} else if ((argcount = parse_long_opt(\"encoding\", argv, &optarg))) {\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 924ba53..e6537ab 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log -F -E --grep=<ere> uses ere' '\n+\techo second >expect &&\n+\tgit log -1 --pretty=\"tformat:%s\" -F -E --grep=s.c.nd >actual &&\n+\ttest_cmp expect actual\n+'\n+\n cat > expect <<EOF\n * Second\n * sixth\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200890","messageId":"1349855714-17008-7-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 6/7] log --grep: accept --basic-regexp and --perl-regexp","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:13Z","receivedAt":"2012-10-10T07:55:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When we added the \"--perl-regexp\" option (or \"-P\") to \"git grep\", we\nshould have done the same for the commands in the \"git log\" family,\nbut somehow we forgot to do so.  This corrects it, but we will\nreserve the short-and-sweet \"-P\" option for something else for now.\n\nAlso introduce the \"--basic-regexp\" option for completeness, so that\nthe \"last one wins\" principle can be used to defeat an earlier -E\noption, e.g. \"git log -E --basic-regexp --grep='<bre>'\".  Note that\nit cannot have the short \"-G\" option as the option is to grep in the\npatch text in the context of \"log\" family.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/rev-list-options.txt | 10 ++++++++++\n revision.c                         |  4 ++++\n 2 files changed, 14 insertions(+)\n\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex ee49743..1ec14a0 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -79,6 +79,11 @@ if it is part of the log message.\n \n \tMatch the regexp limiting patterns without regard to letters case.\n \n+--basic-regexp::\n+\n+\tConsider the limiting patterns to be basic regular expressions;\n+\tthis is the default.\n+\n -E::\n --extended-regexp::\n \n@@ -91,6 +96,11 @@ if it is part of the log message.\n \tConsider the limiting patterns to be fixed strings (don't interpret\n \tpattern as a regular expression).\n \n+--perl-regexp::\n+\n+\tConsider the limiting patterns to be Perl-compatible regexp.\n+\tRequires libpcre to be compiled in.\n+\n --remove-empty::\n \n \tStop when a given path disappears from the tree.\ndiff --git a/revision.c b/revision.c\nindex 68545c8..d7d621c 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1603,6 +1603,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\treturn argcount;\n \t} else if (!strcmp(arg, \"--grep-debug\")) {\n \t\trevs->grep_filter.debug = 1;\n+\t} else if (!strcmp(arg, \"--basic-regexp\")) {\n+\t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_BRE, &revs->grep_filter);\n \t} else if (!strcmp(arg, \"--extended-regexp\") || !strcmp(arg, \"-E\")) {\n \t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n@@ -1610,6 +1612,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\tDIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\n \t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);\n+\t} else if (!strcmp(arg, \"--perl-regexp\")) {\n+\t\tgrep_set_pattern_type_option(GREP_PATTERN_TYPE_PCRE, &revs->grep_filter);\n \t} else if (!strcmp(arg, \"--all-match\")) {\n \t\trevs->grep_filter.all_match = 1;\n \t} else if ((argcount = parse_long_opt(\"encoding\", argv, &optarg))) {\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200891","messageId":"1349855714-17008-8-git-send-email-gitster@pobox.com","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 7/7] log: honor grep.* configuration","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T07:55:14Z","receivedAt":"2012-10-10T07:55:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Now the grep_config() callback is reusable from other configuration\ncallbacks, call it from git_log_config() so that grep.patterntype\nand friends can be used with the commands in the \"git log\" family.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 09cf43e..e7b7db1 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -351,7 +351,8 @@ static int git_log_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!prefixcmp(var, \"color.decorate.\"))\n \t\treturn parse_decorate_color_config(var, 15, value);\n-\n+\tif (grep_config(var, value, cb) < 0)\n+\t\treturn -1;\n \treturn git_diff_ui_config(var, value, cb);\n }\n \n@@ -360,6 +361,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \tstruct setup_revision_opt opt;\n \n+\tinit_grep_defaults();\n \tgit_config(git_log_config, NULL);\n \n \tinit_revisions(&rev, prefix);\n@@ -450,6 +452,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)\n \tstruct pathspec match_all;\n \tint i, count, ret = 0;\n \n+\tinit_grep_defaults();\n \tgit_config(git_log_config, NULL);\n \n \tinit_pathspec(&match_all, NULL);\n@@ -530,6 +533,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \tstruct setup_revision_opt opt;\n \n+\tinit_grep_defaults();\n \tgit_config(git_log_config, NULL);\n \n \tinit_revisions(&rev, prefix);\n@@ -552,6 +556,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)\n \tstruct rev_info rev;\n \tstruct setup_revision_opt opt;\n \n+\tinit_grep_defaults();\n \tgit_config(git_log_config, NULL);\n \n \tinit_revisions(&rev, prefix);\n@@ -1121,6 +1126,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \textra_hdr.strdup_strings = 1;\n \textra_to.strdup_strings = 1;\n \textra_cc.strdup_strings = 1;\n+\tinit_grep_defaults();\n \tgit_config(git_format_config, NULL);\n \tinit_revisions(&rev, prefix);\n \trev.commit_format = CMIT_FMT_EMAIL;\n-- \n1.8.0.rc1.76.g5a375e6\n"},{"id":"200927","messageId":"5075919F.5030306@alum.mit.edu","threadId":"31777","inReplyTo":"1349855714-17008-1-git-send-email-gitster@pobox.com","subject":"Re: [PATCH v2 0/7] Tying loose ends on grep-pcre","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-10-10T15:17:51Z","receivedAt":"2012-10-10T15:17:51Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 10/10/2012 09:55 AM, Junio C Hamano wrote:\n> It took longer than expected, but here is a reroll of the previous\n> series to bring more recent \"git grep\" enhancements to the \"--grep\"\n> option of commands in \"git log\" family.\n> \n> The early part of the series (1-3) refactors the code that reads\n> configuration items related to \"grep\" and the code that mixes the\n> result with the command line options to prepare grep_opt, which so\n> far lived in builtin/grep.c, and moves them to the grep.[ch] at the\n> top-level.\n> \n> The middle part (4-6) reuses the code to set-up grep_opt refactored\n> by the earlier part of the series on revs->grep_filter that is used\n> in \"git log --grep=...\" processing.  It incidentally fixes a small\n> bug where \"git log -F -E --grep='<ere>'\" did not look for matches to\n> the pattern in extended regular expression, and adds --basic-regexp\n> and --perl-regexp command line options to \"git log\" family for\n> completeness.\n> \n> The last one teaches \"git log\" family to honor the \"grep.*\"\n> configuration variables, e.g. \"grep.patterntype\", so that you can\n> say \"git -c grep.patterntype=perl log --grep='(?:pcre)'\".\n\nMaybe this has been discussed already, but it seems to me that adding a\npersistent setting that affects how \"git log --grep\" interprets the\npattern argument could break some scripts that assume that the \"old\"\ninterpretation is always used.  Shouldn't this at least be documented as\na backwards incompatibility?\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"200929","messageId":"7vlifeclrh.fsf@alter.siamese.dyndns.org","threadId":"31777","inReplyTo":"5075919F.5030306@alum.mit.edu","subject":"Re: [PATCH v2 0/7] Tying loose ends on grep-pcre","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-10T16:52:34Z","receivedAt":"2012-10-10T16:52:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n>> The last one teaches \"git log\" family to honor the \"grep.*\"\n>> configuration variables, e.g. \"grep.patterntype\", so that you can\n>> say \"git -c grep.patterntype=perl log --grep='(?:pcre)'\".\n>\n> Maybe this has been discussed already, but it seems to me that adding a\n> persistent setting that affects how \"git log --grep\" interprets the\n> pattern argument could break some scripts that assume that the \"old\"\n> interpretation is always used.  Shouldn't this at least be documented as\n> a backwards incompatibility?\n\nIf somebody scripts around \"log\" with hardcoded query \"--grep=...\"\nstrings, they can force a particular variant from such a command\nline at the same time.  But as always, responsibility of doing so is\non the person who writes such a script; \"log\" being a Porcelain, we\nvalue ease-of-use in interactive case more than cast-in-stone\ninterface stability like we do for plumbing commands.\n\nAnd that is exactly why the series avoids changing the behaviour for\nthe \"rev-list\" plumbing.\n"},{"id":"200978","messageId":"50767073.50800@alum.mit.edu","threadId":"31777","inReplyTo":"7vlifeclrh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 0/7] Tying loose ends on grep-pcre","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-10-11T07:08:35Z","receivedAt":"2012-10-11T07:08:35Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 10/10/2012 06:52 PM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>>> The last one teaches \"git log\" family to honor the \"grep.*\"\n>>> configuration variables, e.g. \"grep.patterntype\", so that you can\n>>> say \"git -c grep.patterntype=perl log --grep='(?:pcre)'\".\n>>\n>> Maybe this has been discussed already, but it seems to me that adding a\n>> persistent setting that affects how \"git log --grep\" interprets the\n>> pattern argument could break some scripts that assume that the \"old\"\n>> interpretation is always used.  Shouldn't this at least be documented as\n>> a backwards incompatibility?\n> \n> If somebody scripts around \"log\" with hardcoded query \"--grep=...\"\n> strings, they can force a particular variant from such a command\n> line at the same time.  But as always, responsibility of doing so is\n> on the person who writes such a script; \"log\" being a Porcelain, we\n> value ease-of-use in interactive case more than cast-in-stone\n> interface stability like we do for plumbing commands.\n> \n> And that is exactly why the series avoids changing the behaviour for\n> the \"rev-list\" plumbing.\n\nOK, you've convinced me.  Thanks.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"}]}