{"thread":{"id":"36125","subject":"[PATCH 1/2] t7810: add missing variables to tests in loop","startedAt":"2014-03-11T21:07:58Z","lastAt":"2014-03-11T21:15:49Z","messageCount":2,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"236538","messageId":"531F7B2E.20209@web.de","threadId":"36125","inReplyTo":null,"subject":"[PATCH 1/2] t7810: add missing variables to tests in loop","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2014-03-11T21:07:58Z","receivedAt":"2014-03-11T21:07:58Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Some tests in t7810-grep.sh are in a loop that runs them against HEAD and\nthe work tree.  In order for that to work the test code should use the\nvariables $L (display name), $H (HEAD or empty string) and $HC (revision\nprefix for result lines); otherwise tests are just repeated with the same\ntarget.  Add the variables where they're missing and make sure the test\ndescription is wrapped in double quotes (instead of single quotes) to\nallow variables to be expanded.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n t/t7810-grep.sh | 58 ++++++++++++++++++++++++++++-----------------------------\n 1 file changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex f698001..46aaebc 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -105,7 +105,7 @@ do\n \n \ttest_expect_success \"grep -w $L (w)\" '\n \t\t: >expected &&\n-\t\ttest_must_fail git grep -n -w -e \"^w\" >actual &&\n+\t\ttest_must_fail git grep -n -w -e \"^w\" $H >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n@@ -240,92 +240,92 @@ do\n \t\ttest_cmp expected actual\n \t'\n \ttest_expect_success \"grep $L with grep.extendedRegexp=false\" '\n-\t\techo \"ab:a+bc\" >expected &&\n-\t\tgit -c grep.extendedRegexp=false grep \"a+b*c\" ab >actual &&\n+\t\techo \"${HC}ab:a+bc\" >expected &&\n+\t\tgit -c grep.extendedRegexp=false grep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.extendedRegexp=true\" '\n-\t\techo \"ab:abc\" >expected &&\n-\t\tgit -c grep.extendedRegexp=true grep \"a+b*c\" ab >actual &&\n+\t\techo \"${HC}ab:abc\" >expected &&\n+\t\tgit -c grep.extendedRegexp=true grep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.patterntype=basic\" '\n-\t\techo \"ab:a+bc\" >expected &&\n-\t\tgit -c grep.patterntype=basic grep \"a+b*c\" ab >actual &&\n+\t\techo \"${HC}ab:a+bc\" >expected &&\n+\t\tgit -c grep.patterntype=basic grep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.patterntype=extended\" '\n-\t\techo \"ab:abc\" >expected &&\n-\t\tgit -c grep.patterntype=extended grep \"a+b*c\" ab >actual &&\n+\t\techo \"${HC}ab:abc\" >expected &&\n+\t\tgit -c grep.patterntype=extended grep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.patterntype=fixed\" '\n-\t\techo \"ab:a+b*c\" >expected &&\n-\t\tgit -c grep.patterntype=fixed grep \"a+b*c\" ab >actual &&\n+\t\techo \"${HC}ab:a+b*c\" >expected &&\n+\t\tgit -c grep.patterntype=fixed grep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success LIBPCRE \"grep $L with grep.patterntype=perl\" '\n-\t\techo \"ab:a+b*c\" >expected &&\n-\t\tgit -c grep.patterntype=perl grep \"a\\x{2b}b\\x{2a}c\" ab >actual &&\n+\t\techo \"${HC}ab:a+b*c\" >expected &&\n+\t\tgit -c grep.patterntype=perl grep \"a\\x{2b}b\\x{2a}c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.patternType=default and grep.extendedRegexp=true\" '\n-\t\techo \"ab:abc\" >expected &&\n+\t\techo \"${HC}ab:abc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.patternType=default \\\n \t\t\t-c grep.extendedRegexp=true \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n \ttest_expect_success \"grep $L with grep.extendedRegexp=true and grep.patternType=default\" '\n-\t\techo \"ab:abc\" >expected &&\n+\t\techo \"${HC}ab:abc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.extendedRegexp=true \\\n \t\t\t-c grep.patternType=default \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n-\ttest_expect_success 'grep $L with grep.patternType=extended and grep.extendedRegexp=false' '\n-\t\techo \"ab:abc\" >expected &&\n+\ttest_expect_success \"grep $L with grep.patternType=extended and grep.extendedRegexp=false\" '\n+\t\techo \"${HC}ab:abc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.patternType=extended \\\n \t\t\t-c grep.extendedRegexp=false \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n-\ttest_expect_success 'grep $L with grep.patternType=basic and grep.extendedRegexp=true' '\n-\t\techo \"ab:a+bc\" >expected &&\n+\ttest_expect_success \"grep $L with grep.patternType=basic and grep.extendedRegexp=true\" '\n+\t\techo \"${HC}ab:a+bc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.patternType=basic \\\n \t\t\t-c grep.extendedRegexp=true \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n-\ttest_expect_success 'grep $L with grep.extendedRegexp=false and grep.patternType=extended' '\n-\t\techo \"ab:abc\" >expected &&\n+\ttest_expect_success \"grep $L with grep.extendedRegexp=false and grep.patternType=extended\" '\n+\t\techo \"${HC}ab:abc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.extendedRegexp=false \\\n \t\t\t-c grep.patternType=extended \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n \n-\ttest_expect_success 'grep $L with grep.extendedRegexp=true and grep.patternType=basic' '\n-\t\techo \"ab:a+bc\" >expected &&\n+\ttest_expect_success \"grep $L with grep.extendedRegexp=true and grep.patternType=basic\" '\n+\t\techo \"${HC}ab:a+bc\" >expected &&\n \t\tgit \\\n \t\t\t-c grep.extendedRegexp=true \\\n \t\t\t-c grep.patternType=basic \\\n-\t\t\tgrep \"a+b*c\" ab >actual &&\n+\t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n done\n-- \n1.9.0\n"},{"id":"236539","messageId":"531F7D05.5010207@web.de","threadId":"36125","inReplyTo":"531F7B2E.20209@web.de","subject":"[PATCH 2/2] grep: support -h (no header) with --count","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2014-03-11T21:15:49Z","receivedAt":"2014-03-11T21:15:49Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Suppress printing the header (filename) with -h even if in -c/--count\nmode.  GNU grep and OpenBSD's grep do the same.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n grep.c          |  7 +++++--\n t/t7810-grep.sh | 12 ++++++++++++\n 2 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex c668034..94f7290 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1562,8 +1562,11 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle\n \t */\n \tif (opt->count && count) {\n \t\tchar buf[32];\n-\t\toutput_color(opt, gs->name, strlen(gs->name), opt->color_filename);\n-\t\toutput_sep(opt, ':');\n+\t\tif (opt->pathname) {\n+\t\t\toutput_color(opt, gs->name, strlen(gs->name),\n+\t\t\t\t     opt->color_filename);\n+\t\t\toutput_sep(opt, ':');\n+\t\t}\n \t\tsnprintf(buf, sizeof(buf), \"%u\\n\", count);\n \t\topt->output(opt, buf, strlen(buf));\n \t\treturn 1;\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex 46aaebc..63b3039 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -328,6 +328,18 @@ do\n \t\t\tgrep \"a+b*c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n \t'\n+\n+\ttest_expect_success \"grep --count $L\" '\n+\t\techo ${HC}ab:3 >expected &&\n+\t\tgit grep --count -e b $H -- ab >actual &&\n+\t\ttest_cmp expected actual\n+\t'\n+\n+\ttest_expect_success \"grep --count -h $L\" '\n+\t\techo 3 >expected &&\n+\t\tgit grep --count -h -e b $H -- ab >actual &&\n+\t\ttest_cmp expected actual\n+\t'\n done\n \n cat >expected <<EOF\n-- \n1.9.0\n"}]}