{"thread":{"id":"4023","subject":"[PATCH] repo-config: support --get-regexp and fix crash","startedAt":"2006-05-02T12:22:48Z","lastAt":"2006-05-03T12:41:03Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"19362","messageId":"Pine.LNX.4.63.0605021422150.7051@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4023","inReplyTo":null,"subject":"[PATCH] repo-config: support --get-regexp and fix crash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-02T12:22:48Z","receivedAt":"2006-05-02T12:22:48Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith --get-regexp, output all key/value pairs where the key matches a\nregexp. Example:\n\n\tgit-repo-config --get-regexp remote.*.url\n\nwill output something like\n\n\tremote.junio.url git://git.kernel.org/pub/scm/git/git.git\n\tremote.gitk.url git://git.kernel.org/pub/scm/gitk/gitk.git\n\nThis also fixes a crash when no arguments are given, which was introduced\nwith the \"-l\" and \"--list\" handling.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tJunio made me aware of a crash, a fix for which was too easy to\n\tmerit a separate patch.\n\n\tStrange thing I realized: A value is white-space-trimmed at the end\n\tonly if the line does not end with a comment. This fact is accounted\n\tfor in the new tests.\n\n Documentation/git-repo-config.txt |    5 +++-\n repo-config.c                     |   45 +++++++++++++++++++++++++++++--------\n t/t1300-repo-config.sh            |   23 +++++++++++++++++++\n 3 files changed, 62 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt\nindex 566cfa1..ddcf523 100644\n--- a/Documentation/git-repo-config.txt\n+++ b/Documentation/git-repo-config.txt\n@@ -49,7 +49,7 @@ OPTIONS\n \n --replace-all::\n \tDefault behaviour is to replace at most one line. This replaces\n-\tall lines matching the key (and optionally the value_regex)\n+\tall lines matching the key (and optionally the value_regex).\n \n --get::\n \tGet the value for a given key (optionally filtered by a regex\n@@ -59,6 +59,9 @@ OPTIONS\n \tLike get, but does not fail if the number of values for the key\n \tis not exactly one.\n \n+--get-regexp::\n+\tLike --get-all, but interprets the name as a regular expression.\n+\n --unset::\n \tRemove the line matching the key from .git/config.\n \ndiff --git a/repo-config.c b/repo-config.c\nindex fa8aba7..722153c 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -6,7 +6,10 @@ static const char git_config_set_usage[]\n \n static char* key = NULL;\n static char* value = NULL;\n+static regex_t* key_regexp = NULL;\n static regex_t* regexp = NULL;\n+static int show_keys = 0;\n+static int use_key_regexp = 0;\n static int do_all = 0;\n static int do_not_match = 0;\n static int seen = 0;\n@@ -26,16 +29,18 @@ static int show_config(const char* key_,\n \tif (value_ == NULL)\n \t\tvalue_ = \"\";\n \n-\tif (!strcmp(key_, key) &&\n+\tif ((use_key_regexp || !strcmp(key_, key)) &&\n+\t\t\t(!use_key_regexp ||\n+\t\t\t !regexec(key_regexp, key_, 0, NULL, 0)) &&\n \t\t\t(regexp == NULL ||\n \t\t\t (do_not_match ^\n \t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n-\t\tif (do_all) {\n-\t\t\tprintf(\"%s\\n\", value_);\n-\t\t\treturn 0;\n-\t\t}\n+\t\tif (show_keys)\n+\t\t\tprintf(\"%s \", key_);\n \t\tif (seen > 0) {\n-\t\t\tfprintf(stderr, \"More than one value: %s\\n\", value);\n+\t\t\tif (!do_all)\n+\t\t\t\tfprintf(stderr, \"More than one value: %s\\n\",\n+\t\t\t\t\t\tvalue);\n \t\t\tfree(value);\n \t\t}\n \n@@ -50,6 +55,8 @@ static int show_config(const char* key_,\n \t\t\tvalue = strdup(value_);\n \t\t}\n \t\tseen++;\n+\t\tif (do_all)\n+\t\t\tprintf(\"%s\\n\", value);\n \t}\n \treturn 0;\n }\n@@ -63,6 +70,14 @@ static int get_value(const char* key_, c\n \t\tkey[i] = tolower(key_[i]);\n \tkey[i] = 0;\n \n+\tif (use_key_regexp) {\n+\t\tkey_regexp = (regex_t*)malloc(sizeof(regex_t));\n+\t\tif (regcomp(key_regexp, key, REG_EXTENDED)) {\n+\t\t\tfprintf(stderr, \"Invalid key pattern: %s\\n\", regex_);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n \tif (regex_) {\n \t\tif (regex_[0] == '!') {\n \t\t\tdo_not_match = 1;\n@@ -78,7 +93,8 @@ static int get_value(const char* key_, c\n \n \tgit_config(show_config);\n \tif (value) {\n-\t\tprintf(\"%s\\n\", value);\n+\t\tif (!do_all)\n+\t\t\tprintf(\"%s\\n\", value);\n \t\tfree(value);\n \t}\n \tfree(key);\n@@ -102,15 +118,14 @@ int main(int argc, const char **argv)\n \t\t\ttype = T_INT;\n \t\telse if (!strcmp(argv[1], \"--bool\"))\n \t\t\ttype = T_BOOL;\n+\t\telse if (!strcmp(argv[1], \"--list\") || !strcmp(argv[1], \"-l\"))\n+\t\t\treturn git_config(show_all_config);\n \t\telse\n \t\t\tbreak;\n \t\targc--;\n \t\targv++;\n \t}\n \n-\tif (!strcmp(argv[1], \"--list\") || !strcmp(argv[1], \"-l\"))\n-\t\treturn git_config(show_all_config);\n-\n \tswitch (argc) {\n \tcase 2:\n \t\treturn get_value(argv[1], NULL);\n@@ -124,6 +139,11 @@ int main(int argc, const char **argv)\n \t\telse if (!strcmp(argv[1], \"--get-all\")) {\n \t\t\tdo_all = 1;\n \t\t\treturn get_value(argv[2], NULL);\n+\t\t} else if (!strcmp(argv[1], \"--get-regexp\")) {\n+\t\t\tshow_keys = 1;\n+\t\t\tuse_key_regexp = 1;\n+\t\t\tdo_all = 1;\n+\t\t\treturn get_value(argv[2], NULL);\n \t\t} else\n \n \t\t\treturn git_config_set(argv[1], argv[2]);\n@@ -137,6 +157,11 @@ int main(int argc, const char **argv)\n \t\telse if (!strcmp(argv[1], \"--get-all\")) {\n \t\t\tdo_all = 1;\n \t\t\treturn get_value(argv[2], argv[3]);\n+\t\t} else if (!strcmp(argv[1], \"--get-regexp\")) {\n+\t\t\tshow_keys = 1;\n+\t\t\tuse_key_regexp = 1;\n+\t\t\tdo_all = 1;\n+\t\t\treturn get_value(argv[2], argv[3]);\n \t\t} else if (!strcmp(argv[1], \"--replace-all\"))\n \n \t\t\treturn git_config_set_multivar(argv[2], argv[3], NULL, 1);\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex ab4dd5c..52e8e33 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -247,6 +247,24 @@ EOF\n \n test_expect_success 'hierarchical section value' 'cmp .git/config expect'\n \n+cat > expect << EOF\n+beta.noindent=sillyValue \n+nextsection.nonewline=wow2 for me\n+123456.a123=987\n+1.2.3.alpha=beta\n+EOF\n+\n+test_expect_success 'working --list' \\\n+\t'git-repo-config --list > output && cmp output expect'\n+\n+cat > expect << EOF\n+beta.noindent sillyValue \n+nextsection.nonewline wow2 for me\n+EOF\n+\n+test_expect_success '--get-regexp' \\\n+\t'git-repo-config --get-regexp in > output && cmp output expect'\n+\n cat > .git/config << EOF\n [novalue]\n \tvariable\n@@ -255,5 +273,10 @@ EOF\n test_expect_success 'get variable with no value' \\\n \t'git-repo-config --get novalue.variable ^$'\n \n+git-repo-config > output 2>&1\n+\n+test_expect_success 'no arguments, but no crash' \\\n+\t\"test $? = 129 && grep usage output\"\n+\n test_done\n \n"},{"id":"19387","messageId":"7vmze0j97u.fsf@assigned-by-dhcp.cox.net","threadId":"4023","inReplyTo":"Pine.LNX.4.63.0605021422150.7051@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] repo-config: support --get-regexp and fix crash","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-02T23:30:29Z","receivedAt":"2006-05-02T23:30:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \tJunio made me aware of a crash, a fix for which was too easy to\n> \tmerit a separate patch.\n\nNot really.  The fix is clean-and-obvious, and is readily\napplicable to \"master\" without being cooked in \"next\".  On the\nother hand, --get-regexp may or may not be so; by conflating the\ntwo, you are delaying the trivial and useful fix unnecessarily.\n\nI already split the patch and applied the fix on \"master\", while\nkeeping the rest in \"pu\" (sorry, I ran out of patience to test\neverything to put it in \"next\" -- will do so tomorrow).\n\nIt is usually a good idea to avoid making an otherwise good\nclean patch a hostage to new features (intentionally or\naccidentally).\n\n> \tStrange thing I realized: A value is white-space-trimmed at the end\n> \tonly if the line does not end with a comment. This fact is accounted\n> \tfor in the new tests.\n\nThanks - a note like this helps me quite a bit, because I\nusually apply e-mailed patches with --whitespace=strip, which\nwould have destroyed the test, leaving me scratching my head\nwithout such a notice.\n"},{"id":"19401","messageId":"7vlktjhhvc.fsf@assigned-by-dhcp.cox.net","threadId":"4023","inReplyTo":"Pine.LNX.4.63.0605021422150.7051@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] repo-config: support --get-regexp and fix crash","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-03T04:06:31Z","receivedAt":"2006-05-03T04:06:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> diff --git a/repo-config.c b/repo-config.c\n> index fa8aba7..722153c 100644\n> --- a/repo-config.c\n> +++ b/repo-config.c\n> @@ -6,7 +6,10 @@ static const char git_config_set_usage[]\n\nNew flag missing from usage.\n\n>  \n>  static char* key = NULL;\n>  static char* value = NULL;\n> +static regex_t* key_regexp = NULL;\n>  static regex_t* regexp = NULL;\n> +static int show_keys = 0;\n> +static int use_key_regexp = 0;\n>  static int do_all = 0;\n>  static int do_not_match = 0;\n>  static int seen = 0;\n> @@ -26,16 +29,18 @@ static int show_config(const char* key_,\n>  \tif (value_ == NULL)\n>  \t\tvalue_ = \"\";\n>  \n> -\tif (!strcmp(key_, key) &&\n> +\tif ((use_key_regexp || !strcmp(key_, key)) &&\n> +\t\t\t(!use_key_regexp ||\n> +\t\t\t !regexec(key_regexp, key_, 0, NULL, 0)) &&\n>  \t\t\t(regexp == NULL ||\n>  \t\t\t (do_not_match ^\n>  \t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n\nThat's a convoluted logic.\n\n (1) Either we are using key-regexp, or otherwise the key has to\n     exactly match; and\n\n (2) Either we are not using key-regexp, or key-regexp must\n     match; and\n\n (3) Either we are not using regexp, or value must match (or\n     unmatch) as we are told by do_no_match.\n\nIt all makes sense, but I wonder if this is the clearest way to\nconvey what is happening to people.  Not that I have a cleaner\nalternative in mind...\n\n> @@ -63,6 +70,14 @@ static int get_value(const char* key_, c\n>  \t\tkey[i] = tolower(key_[i]);\n>  \tkey[i] = 0;\n>  \n> +\tif (use_key_regexp) {\n> +\t\tkey_regexp = (regex_t*)malloc(sizeof(regex_t));\n> +\t\tif (regcomp(key_regexp, key, REG_EXTENDED)) {\n> +\t\t\tfprintf(stderr, \"Invalid key pattern: %s\\n\", regex_);\n> +\t\t\treturn -1;\n> +\t\t}\n> +\t}\n> +\n\nNot worrying about leaking on failure path is just fine, since\nthis is not a libified part.  Perhaps the free() in get_value()\nare all like that -- get_value() is called once immediately\nbefore exiting the program anyway ;-).\n\nTo my deliberately bogus request, I am getting (null); fprintf()\nshould use \"key\" instead of \"regex_\", perhaps?\n\n\t$ git-repo-config --get-regexp 'core['\n        Invalid key pattern: (null)\n\n> @@ -78,7 +93,8 @@ static int get_value(const char* key_, c\n>  \n>  \tgit_config(show_config);\n>  \tif (value) {\n> -\t\tprintf(\"%s\\n\", value);\n> +\t\tif (!do_all)\n> +\t\t\tprintf(\"%s\\n\", value);\n>  \t\tfree(value);\n>  \t}\n>  \tfree(key);\n\nI wonder if it would make things cleaner if you do not keep the\nglobal \"value\" around.  Instead, do all the printing in\nshow_config(), using a static global bool \"seen\" to control\ndo_all vs get-all request as you already do.  Then get_value()\ndoes not even need to worry about freeing the value, does it?\n\nAlso I am not sure if \"say OK if do_all was requested\" at the\nend of get_value().  If a do_all request did not find any match,\nis it an OK condition?  I do not have strong feeling either way,\nthough.\n\nA suggested patch on top of your version that is in \"pu\".\n\n-- >8 --\ndiff --git a/repo-config.c b/repo-config.c\nindex 722153c..7e06d1a 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -2,10 +2,9 @@ #include \"cache.h\"\n #include <regex.h>\n \n static const char git_config_set_usage[] =\n-\"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list\";\n+\"git-repo-config [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list\";\n \n static char* key = NULL;\n-static char* value = NULL;\n static regex_t* key_regexp = NULL;\n static regex_t* regexp = NULL;\n static int show_keys = 0;\n@@ -26,6 +25,9 @@ static int show_all_config(const char *k\n \n static int show_config(const char* key_, const char* value_)\n {\n+\tchar value[256];\n+\tconst char *vptr = value;\n+\n \tif (value_ == NULL)\n \t\tvalue_ = \"\";\n \n@@ -35,28 +37,25 @@ static int show_config(const char* key_,\n \t\t\t(regexp == NULL ||\n \t\t\t (do_not_match ^\n \t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n+\t\tint dup_error = 0;\n \t\tif (show_keys)\n \t\t\tprintf(\"%s \", key_);\n-\t\tif (seen > 0) {\n-\t\t\tif (!do_all)\n-\t\t\t\tfprintf(stderr, \"More than one value: %s\\n\",\n-\t\t\t\t\t\tvalue);\n-\t\t\tfree(value);\n-\t\t}\n-\n-\t\tif (type == T_INT) {\n-\t\t\tvalue = malloc(256);\n+\t\tif (seen && !do_all)\n+\t\t\tdup_error = 1;\n+\t\tif (type == T_INT)\n \t\t\tsprintf(value, \"%d\", git_config_int(key_, value_));\n-\t\t} else if (type == T_BOOL) {\n-\t\t\tvalue = malloc(256);\n+\t\telse if (type == T_BOOL)\n \t\t\tsprintf(value, \"%s\", git_config_bool(key_, value_)\n \t\t\t\t\t     ? \"true\" : \"false\");\n-\t\t} else {\n-\t\t\tvalue = strdup(value_);\n-\t\t}\n+\t\telse\n+\t\t\tvptr = value_;\n \t\tseen++;\n-\t\tif (do_all)\n-\t\t\tprintf(\"%s\\n\", value);\n+\t\tif (dup_error) {\n+\t\t\terror(\"More than one value for the key %s: %s\",\n+\t\t\t      key_, vptr);\n+\t\t}\n+\t\telse\n+\t\t\tprintf(\"%s\\n\", vptr);\n \t}\n \treturn 0;\n }\n@@ -73,7 +72,7 @@ static int get_value(const char* key_, c\n \tif (use_key_regexp) {\n \t\tkey_regexp = (regex_t*)malloc(sizeof(regex_t));\n \t\tif (regcomp(key_regexp, key, REG_EXTENDED)) {\n-\t\t\tfprintf(stderr, \"Invalid key pattern: %s\\n\", regex_);\n+\t\t\tfprintf(stderr, \"Invalid key pattern: %s\\n\", key_);\n \t\t\treturn -1;\n \t\t}\n \t}\n@@ -92,11 +91,6 @@ static int get_value(const char* key_, c\n \t}\n \n \tgit_config(show_config);\n-\tif (value) {\n-\t\tif (!do_all)\n-\t\t\tprintf(\"%s\\n\", value);\n-\t\tfree(value);\n-\t}\n \tfree(key);\n \tif (regexp) {\n \t\tregfree(regexp);\n@@ -104,9 +98,9 @@ static int get_value(const char* key_, c\n \t}\n \n \tif (do_all)\n-\t\treturn 0;\n+\t\treturn !seen;\n \n-\treturn seen == 1 ? 0 : 1;\n+\treturn (seen == 1) ? 0 : 1;\n }\n \n int main(int argc, const char **argv)\n"},{"id":"19421","messageId":"Pine.LNX.4.63.0605031353300.4017@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4023","inReplyTo":"7vmze0j97u.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] repo-config: support --get-regexp and fix crash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-03T11:55:52Z","receivedAt":"2006-05-03T11:55:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 2 May 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > \tJunio made me aware of a crash, a fix for which was too easy to\n> > \tmerit a separate patch.\n> \n> Not really.\n\nRight. I was just too lazy.\n\n> > \tStrange thing I realized: A value is white-space-trimmed at the end\n> > \tonly if the line does not end with a comment. This fact is accounted\n> > \tfor in the new tests.\n> \n> Thanks - a note like this helps me quite a bit, because I\n> usually apply e-mailed patches with --whitespace=strip, which\n> would have destroyed the test, leaving me scratching my head\n> without such a notice.\n\nApparently, I hid that note well: somebody complained privately that my \npatch is not white-space clean.\n\nAs for the --get-regexp part: just take your time. It was easy enough, and \nI think it is quite cool, but I have to see an application for it yet.\n\nCiao,\nDscho\n"},{"id":"19426","messageId":"Pine.LNX.4.63.0605031438510.6340@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4023","inReplyTo":"7vlktjhhvc.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] repo-config: support --get-regexp and fix crash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-05-03T12:41:03Z","receivedAt":"2006-05-03T12:41:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nthanks for your patch.\n\nOn Tue, 2 May 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > @@ -26,16 +29,18 @@ static int show_config(const char* key_,\n> >  \tif (value_ == NULL)\n> >  \t\tvalue_ = \"\";\n> >  \n> > -\tif (!strcmp(key_, key) &&\n> > +\tif ((use_key_regexp || !strcmp(key_, key)) &&\n> > +\t\t\t(!use_key_regexp ||\n> > +\t\t\t !regexec(key_regexp, key_, 0, NULL, 0)) &&\n> >  \t\t\t(regexp == NULL ||\n> >  \t\t\t (do_not_match ^\n> >  \t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n> \n> That's a convoluted logic.\n> \n>  (1) Either we are using key-regexp, or otherwise the key has to\n>      exactly match; and\n> \n>  (2) Either we are not using key-regexp, or key-regexp must\n>      match; and\n> \n>  (3) Either we are not using regexp, or value must match (or\n>      unmatch) as we are told by do_no_match.\n> \n> It all makes sense, but I wonder if this is the clearest way to\n> convey what is happening to people.  Not that I have a cleaner\n> alternative in mind...\n\nHow about this (on top of your patch):\n\n--- snip ---\n[PATCH] repo-config: deconvolute logics\n\nIt was rightly noticed that the logic is quite convoluted. Fix that.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tThe real change is very short, but a code block got reindented, \n\ttoo.\n\n repo-config.c |   50 ++++++++++++++++++++++++++------------------------\n 1 files changed, 26 insertions(+), 24 deletions(-)\n\ndiff --git a/repo-config.c b/repo-config.c\nindex 7e06d1a..63eda1b 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -27,36 +27,38 @@ static int show_config(const char* key_,\n {\n \tchar value[256];\n \tconst char *vptr = value;\n+\tint dup_error = 0;\n \n \tif (value_ == NULL)\n \t\tvalue_ = \"\";\n \n-\tif ((use_key_regexp || !strcmp(key_, key)) &&\n-\t\t\t(!use_key_regexp ||\n-\t\t\t !regexec(key_regexp, key_, 0, NULL, 0)) &&\n-\t\t\t(regexp == NULL ||\n+\tif (!use_key_regexp && strcmp(key_, key))\n+\t\treturn 0;\n+\tif (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))\n+\t\treturn 0;\n+\tif (regexp != NULL &&\n \t\t\t (do_not_match ^\n-\t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n-\t\tint dup_error = 0;\n-\t\tif (show_keys)\n-\t\t\tprintf(\"%s \", key_);\n-\t\tif (seen && !do_all)\n-\t\t\tdup_error = 1;\n-\t\tif (type == T_INT)\n-\t\t\tsprintf(value, \"%d\", git_config_int(key_, value_));\n-\t\telse if (type == T_BOOL)\n-\t\t\tsprintf(value, \"%s\", git_config_bool(key_, value_)\n-\t\t\t\t\t     ? \"true\" : \"false\");\n-\t\telse\n-\t\t\tvptr = value_;\n-\t\tseen++;\n-\t\tif (dup_error) {\n-\t\t\terror(\"More than one value for the key %s: %s\",\n-\t\t\t      key_, vptr);\n-\t\t}\n-\t\telse\n-\t\t\tprintf(\"%s\\n\", vptr);\n+\t\t\t  regexec(regexp, value_, 0, NULL, 0)))\n+\t\treturn 0;\n+\n+\tif (show_keys)\n+\t\tprintf(\"%s \", key_);\n+\tif (seen && !do_all)\n+\t\tdup_error = 1;\n+\tif (type == T_INT)\n+\t\tsprintf(value, \"%d\", git_config_int(key_, value_));\n+\telse if (type == T_BOOL)\n+\t\tvptr = git_config_bool(key_, value_) ? \"true\" : \"false\";\n+\telse\n+\t\tvptr = value_;\n+\tseen++;\n+\tif (dup_error) {\n+\t\terror(\"More than one value for the key %s: %s\",\n+\t\t\t\tkey_, vptr);\n \t}\n+\telse\n+\t\tprintf(\"%s\\n\", vptr);\n+\n \treturn 0;\n }\n \n"}]}