From 50dd0f2fd910d9973760db052897ee8e73ed2f1f Mon Sep 17 00:00:00 2001 From: Albert Yale Date: Mon, 23 Jan 2012 18:52:44 +0100 Subject: grep: fix -l/-L interaction with decoration lines In threaded mode, git-grep emits file breaks (enabled with context, -W and --break) into the accumulation buffers even if they are not required. The output collection thread then uses skip_first_line to skip the first such line in the output, which would otherwise be at the very top. This is wrong when the user also specified -l/-L/-c, in which case every line is relevant. While arguably giving these options together doesn't make any sense, git-grep has always quietly accepted it. So do not skip anything in these cases. Signed-off-by: Albert Yale Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 7ba5b16f99..75f4716d8c 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -245,6 +245,28 @@ do ' done +cat >expected <actual && + test_cmp expected actual +' + +cat >expected <actual && + test_cmp expected actual +' + +test_expect_success 'grep -L -C' ' + git ls-files >expected && + git grep -L -C1 nonexistent_string >actual && + test_cmp expected actual +' + cat >expected < Date: Mon, 27 Feb 2012 17:45:49 +0100 Subject: grep -P: add tests for matching ^ and $ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Earlier, fba4f1 (grep -P: Fix matching ^ and $) fixed an ancient bug. Add some tests to protect the change from future breakages; a slightly broken version of this was a part of the originally submitted patch. Signed-off-by: Michał Kiedrowicz Signed-off-by: Zbigniew Jędrzejewski-Szmek Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 75f4716d8c..d9ad633310 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -47,6 +47,13 @@ test_expect_success setup ' echo vvv >t/v && mkdir t/a && echo vvv >t/a/v && + { + echo "line without leading space1" + echo " line with leading space1" + echo " line with leading space2" + echo " line with leading space3" + echo "line without leading space2" + } >space && git add . && test_tick && git commit -m initial @@ -893,4 +900,20 @@ test_expect_success 'mimic ack-grep --group' ' test_cmp expected actual ' +cat >expected <actual && + test_cmp expected actual +' + +test_expect_success LIBPCRE 'grep -P "^ "' ' + git grep -P "^ " space >actual && + test_cmp expected actual +' + test_done -- cgit v1.2.1 From 526a858a99ace6698823740374edc3e35b87901a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sun, 20 May 2012 16:33:07 +0200 Subject: grep: support newline separated pattern list Currently, patterns that contain newline characters don't match anything when given to git grep. Regular grep(1) interprets patterns as lists of newline separated search strings instead. Implement this functionality by creating and inserting extra grep_pat structures for patterns consisting of multiple lines when appending to the pattern lists. For simplicity, all pattern strings are duplicated. The original pattern is truncated in place to make it contain only the first line. Requested-by: Torne (Richard Coles) Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 6379ad60bc..bc9a522085 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -322,6 +322,11 @@ test_expect_success 'grep -f, multiple patterns' ' test_cmp expected actual ' +test_expect_success 'grep, multiple patterns' ' + git grep "$(cat patterns)" >actual && + test_cmp expected actual +' + cat >expected < Date: Sat, 28 Jul 2012 19:50:49 +0100 Subject: t7810-*.sh: Remove redundant test Since commit bbc09c22 ("grep: rip out support for external grep", 12-01-2010), test number 60 ("grep -C1 hunk mark between files") is essentially the same as test number 59. Test 59 was intended to verify the behaviour of git-grep resulting from multiple invocations of an external grep. As part of the test, it creates and adds 1024 files to the index, which is now wasted effort. Remove test 59, since it is now redundant. Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 11 ----------- 1 file changed, 11 deletions(-) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 75f4716d8c..cd32ac5eb5 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -387,17 +387,6 @@ test_expect_success 'grep -q, silently report matches' ' test_cmp empty actual ' -# Create 1024 file names that sort between "y" and "z" to make sure -# the two files are handled by different calls to an external grep. -# This depends on MAXARGS in builtin-grep.c being 1024 or less. -c32="0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v" -test_expect_success 'grep -C1, hunk mark between files' ' - for a in $c32; do for b in $c32; do : >y-$a$b; done; done && - git add y-?? && - git grep -C1 "^[yz]" >actual && - test_cmp expected actual -' - test_expect_success 'grep -C1 hunk mark between files' ' git grep -C1 "^[yz]" >actual && test_cmp expected actual -- cgit v1.2.1 From 84befcd0a4a074e2ae191c32be09d2e82d5db114 Mon Sep 17 00:00:00 2001 From: J Smith Date: Fri, 3 Aug 2012 10:53:50 -0400 Subject: grep: add a grep.patternType configuration setting The grep.extendedRegexp configuration setting enables the -E flag on grep by default but there are no equivalents for the -G, -F and -P flags. Rather than adding an additional setting for grep.fooRegexp for current and future pattern matching options, add a grep.patternType setting that can accept appropriate values for modifying the default grep pattern matching behavior. The current values are "basic", "extended", "fixed", "perl" and "default" for setting -G, -E, -F, -P and the default behavior respectively. When grep.patternType is set to a value other than "default", the grep.extendedRegexp setting is ignored. The value of "default" restores the current default behavior, including the grep.extendedRegexp behavior. Signed-off-by: J Smith Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 181 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 24e9b1974d..006fecbe38 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -250,6 +250,84 @@ do git -c grep.extendedRegexp=true grep "a+b*c" ab >actual && test_cmp expected actual ' + + test_expect_success "grep $L with grep.patterntype=basic" ' + echo "ab:a+bc" >expected && + git -c grep.patterntype=basic grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success "grep $L with grep.patterntype=extended" ' + echo "ab:abc" >expected && + git -c grep.patterntype=extended grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success "grep $L with grep.patterntype=fixed" ' + echo "ab:a+b*c" >expected && + git -c grep.patterntype=fixed grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success LIBPCRE "grep $L with grep.patterntype=perl" ' + echo "ab:a+b*c" >expected && + git -c grep.patterntype=perl grep "a\x{2b}b\x{2a}c" ab >actual && + test_cmp expected actual + ' + + test_expect_success "grep $L with grep.patternType=default and grep.extendedRegexp=true" ' + echo "ab:abc" >expected && + git \ + -c grep.patternType=default \ + -c grep.extendedRegexp=true \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success "grep $L with grep.extendedRegexp=true and grep.patternType=default" ' + echo "ab:abc" >expected && + git \ + -c grep.extendedRegexp=true \ + -c grep.patternType=default \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success 'grep $L with grep.patternType=extended and grep.extendedRegexp=false' ' + echo "ab:abc" >expected && + git \ + -c grep.patternType=extended \ + -c grep.extendedRegexp=false \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success 'grep $L with grep.patternType=basic and grep.extendedRegexp=true' ' + echo "ab:a+bc" >expected && + git \ + -c grep.patternType=basic \ + -c grep.extendedRegexp=true \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success 'grep $L with grep.extendedRegexp=false and grep.patternType=extended' ' + echo "ab:abc" >expected && + git \ + -c grep.extendedRegexp=false \ + -c grep.patternType=extended \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' + + test_expect_success 'grep $L with grep.extendedRegexp=true and grep.patternType=basic' ' + echo "ab:a+bc" >expected && + git \ + -c grep.extendedRegexp=true \ + -c grep.patternType=basic \ + grep "a+b*c" ab >actual && + test_cmp expected actual + ' done cat >expected <expected && git grep -G -E -F "a+b*c" ab >actual && test_cmp expected actual ' +test_expect_success 'grep pattern with grep.patternType=basic, =extended, =fixed' ' + echo "ab:a+b*c" >expected && + git \ + -c grep.patterntype=basic \ + -c grep.patterntype=extended \ + -c grep.patterntype=fixed \ + grep "a+b*c" ab >actual && + test_cmp expected actual +' + test_expect_success 'grep -E -F -G pattern' ' echo "ab:a+bc" >expected && git grep -E -F -G "a+b*c" ab >actual && test_cmp expected actual ' +test_expect_success 'grep pattern with grep.patternType=extended, =fixed, =basic' ' + echo "ab:a+bc" >expected && + git \ + -c grep.patterntype=extended \ + -c grep.patterntype=fixed \ + -c grep.patterntype=basic \ + grep "a+b*c" ab >actual && + test_cmp expected actual +' + test_expect_success 'grep -F -G -E pattern' ' echo "ab:abc" >expected && git grep -F -G -E "a+b*c" ab >actual && test_cmp expected actual ' +test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =extended' ' + echo "ab:abc" >expected && + git \ + -c grep.patterntype=fixed \ + -c grep.patterntype=basic \ + -c grep.patterntype=extended \ + grep "a+b*c" ab >actual && + test_cmp expected actual +' + test_expect_success 'grep -G -F -P -E pattern' ' >empty && test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual && test_cmp empty actual ' +test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =perl, =extended' ' + >empty && + test_must_fail git \ + -c grep.patterntype=fixed \ + -c grep.patterntype=basic \ + -c grep.patterntype=perl \ + -c grep.patterntype=extended \ + grep "a\x{2b}b\x{2a}c" ab >actual && + test_cmp empty actual +' + test_expect_success LIBPCRE 'grep -G -F -E -P pattern' ' echo "ab:a+b*c" >expected && git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual && test_cmp expected actual ' +test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' ' + echo "ab:a+b*c" >expected && + git \ + -c grep.patterntype=fixed \ + -c grep.patterntype=basic \ + -c grep.patterntype=extended \ + -c grep.patterntype=perl \ + grep "a\x{2b}b\x{2a}c" ab >actual && + test_cmp expected actual +' + +test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=fixed' ' + echo "ab:a+b*c" >expected && + git \ + -c grep.patterntype=fixed \ + grep -P "a\x{2b}b\x{2a}c" ab >actual && + test_cmp expected actual +' + +test_expect_success 'grep -F pattern with grep.patternType=basic' ' + echo "ab:a+b*c" >expected && + git \ + -c grep.patterntype=basic \ + grep -F "*c" ab >actual && + test_cmp expected actual +' + +test_expect_success 'grep -G pattern with grep.patternType=fixed' ' + { + echo "ab:a+b*c" + echo "ab:a+bc" + } >expected && + git \ + -c grep.patterntype=fixed \ + grep -G "a+b" ab >actual && + test_cmp expected actual +' + +test_expect_success 'grep -E pattern with grep.patternType=fixed' ' + { + echo "ab:a+b*c" + echo "ab:a+bc" + echo "ab:abc" + } >expected && + git \ + -c grep.patterntype=fixed \ + grep -E "a+" ab >actual && + test_cmp expected actual +' + test_config() { git config "$1" "$2" && test_when_finished "git config --unset $1" -- cgit v1.2.1 From b327bf74bd631790918d6730404eb97baec267c9 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 Sep 2012 11:46:39 +0200 Subject: t7810-grep: bring log --grep tests in common form The log --grep tests generate the expected out in different ways. Make them all use command blocks so that subshells are avoided and the expected output is easier to grasp visually. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 24e9b1974d..180e998697 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -435,31 +435,41 @@ test_expect_success 'log grep setup' ' test_expect_success 'log grep (1)' ' git log --author=author --pretty=tformat:%s >actual && - ( echo third ; echo initial ) >expect && + { + echo third && echo initial + } >expect && test_cmp expect actual ' test_expect_success 'log grep (2)' ' git log --author=" * " -F --pretty=tformat:%s >actual && - ( echo second ) >expect && + { + echo second + } >expect && test_cmp expect actual ' test_expect_success 'log grep (3)' ' git log --author="^A U" --pretty=tformat:%s >actual && - ( echo third ; echo initial ) >expect && + { + echo third && echo initial + } >expect && test_cmp expect actual ' test_expect_success 'log grep (4)' ' git log --author="frotz\.com>$" --pretty=tformat:%s >actual && - ( echo second ) >expect && + { + echo second + } >expect && test_cmp expect actual ' test_expect_success 'log grep (5)' ' git log --author=Thor -F --pretty=tformat:%s >actual && - ( echo third ; echo initial ) >expect && + { + echo third && echo initial + } >expect && test_cmp expect actual ' @@ -473,7 +483,9 @@ test_expect_success 'log --grep --author implicitly uses all-match' ' # grep matches initial and second but not third # author matches only initial and third git log --author="A U Thor" --grep=s --grep=l --format=%s >actual && - echo initial >expect && + { + echo initial + } >expect && test_cmp expect actual ' -- cgit v1.2.1 From dfe3642515d3d2679bdc25c2be4d961201e9f095 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 Sep 2012 11:46:40 +0200 Subject: t7810-grep: test multiple --grep with and without --all-match Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 180e998697..b841909315 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -479,6 +479,22 @@ test_expect_success 'log grep (6)' ' test_cmp expect actual ' +test_expect_success 'log with multiple --grep uses union' ' + git log --grep=i --grep=r --format=%s >actual && + { + echo fourth && echo third && echo initial + } >expect && + test_cmp expect actual +' + +test_expect_success 'log --all-match with multiple --grep uses intersection' ' + git log --all-match --grep=i --grep=r --format=%s >actual && + { + echo third + } >expect && + test_cmp expect actual +' + test_expect_success 'log --grep --author implicitly uses all-match' ' # grep matches initial and second but not third # author matches only initial and third -- cgit v1.2.1 From 00f62a64d489592c97f6f171f9a19fdda530f3c5 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 Sep 2012 11:46:41 +0200 Subject: t7810-grep: test multiple --author with --all-match The "--all-match" option is about "--grep", and does not affect how "--author" or "--committer" limitation is applied. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index b841909315..be81d96e20 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -513,6 +513,14 @@ test_expect_success 'log with multiple --author uses union' ' test_cmp expect actual ' +test_expect_success 'log --all-match with multiple --author still uses union' ' + git log --all-match --author="Thor" --author="Aster" --format=%s >actual && + { + echo third && echo second && echo initial + } >expect && + test_cmp expect actual +' + test_expect_success 'log with --grep and multiple --author uses all-match' ' git log --author="Thor" --author="Night" --grep=i --format=%s >actual && { -- cgit v1.2.1 From 2cb03e76a0e65920a0790d5b128fde9185e0e8fe Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 Sep 2012 11:46:42 +0200 Subject: t7810-grep: test interaction of multiple --grep and --author options There are tests for this interaction already. Restructure slightly and avoid any claims about --all-match. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index be81d96e20..f6edb4d6dc 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -495,16 +495,6 @@ test_expect_success 'log --all-match with multiple --grep uses intersection' ' test_cmp expect actual ' -test_expect_success 'log --grep --author implicitly uses all-match' ' - # grep matches initial and second but not third - # author matches only initial and third - git log --author="A U Thor" --grep=s --grep=l --format=%s >actual && - { - echo initial - } >expect && - test_cmp expect actual -' - test_expect_success 'log with multiple --author uses union' ' git log --author="Thor" --author="Aster" --format=%s >actual && { @@ -521,17 +511,33 @@ test_expect_success 'log --all-match with multiple --author still uses union' ' test_cmp expect actual ' -test_expect_success 'log with --grep and multiple --author uses all-match' ' - git log --author="Thor" --author="Night" --grep=i --format=%s >actual && +test_expect_success 'log --grep --author uses intersection' ' + # grep matches only third and fourth + # author matches only initial and third + git log --author="A U Thor" --grep=r --format=%s >actual && { - echo third && echo initial + echo third } >expect && test_cmp expect actual ' -test_expect_success 'log with --grep and multiple --author uses all-match' ' - git log --author="Thor" --author="Night" --grep=q --format=%s >actual && - >expect && +test_expect_success 'log --grep --grep --author takes union of greps and intersects with author' ' + # grep matches initial and second but not third + # author matches only initial and third + git log --author="A U Thor" --grep=s --grep=l --format=%s >actual && + { + echo initial + } >expect && + test_cmp expect actual +' + +test_expect_success 'log --grep --author --author takes union of authors and intersects with grep' ' + # grep matches only initial and third + # author matches all but second + git log --author="Thor" --author="Night" --grep=i --format=%s >actual && + { + echo third && echo initial + } >expect && test_cmp expect actual ' -- cgit v1.2.1 From 39f2e017203695b9da2ad35589b0e58bcac6fdc8 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 14 Sep 2012 11:46:43 +0200 Subject: t7810-grep: test --all-match with multiple --grep and --author options The code used to have a bug that ignores "--all-match", that requires all "--grep" to have matched, when "--author" or "--committer" was used. Make sure the bug will not be reintroduced. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index f6edb4d6dc..b5c488e3a5 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -531,6 +531,16 @@ test_expect_success 'log --grep --grep --author takes union of greps and interse test_cmp expect actual ' +test_expect_success 'log ---all-match -grep --author --author still takes union of authors and intersects with grep' ' + # grep matches only initial and third + # author matches all but second + git log --all-match --author="Thor" --author="Night" --grep=i --format=%s >actual && + { + echo third && echo initial + } >expect && + test_cmp expect actual +' + test_expect_success 'log --grep --author --author takes union of authors and intersects with grep' ' # grep matches only initial and third # author matches all but second @@ -541,6 +551,16 @@ test_expect_success 'log --grep --author --author takes union of authors and int test_cmp expect actual ' +test_expect_success 'log --all-match --grep --grep --author takes intersection' ' + # grep matches only third + # author matches only initial and third + git log --all-match --author="A U Thor" --grep=i --grep=r --format=%s >actual && + { + echo third + } >expect && + test_cmp expect actual +' + test_expect_success 'grep with CE_VALID file' ' git update-index --assume-unchanged t/t && rm t/t && -- cgit v1.2.1 From ad4813b3c2513c5dc7e84305ab8a393b32124977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 29 Sep 2012 11:41:27 +0700 Subject: grep: prepare for new header field filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit grep supports only author and committer headers, which have the same special treatment that later headers may or may not have. Check for field type and only strip_timestamp() when the field is either author or committer. GREP_HEADER_FIELD_MAX is put in the grep_header_field enum to be calculated automatically, correctly, as long as it's at the end of the enum. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 91db352cc7..30eaa9a54b 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -628,6 +628,18 @@ test_expect_success 'log --all-match --grep --grep --author takes intersection' test_cmp expect actual ' +test_expect_success 'log --author does not search in timestamp' ' + : >expect && + git log --author="$GIT_AUTHOR_DATE" >actual && + test_cmp expect actual +' + +test_expect_success 'log --committer does not search in timestamp' ' + : >expect && + git log --committer="$GIT_COMMITTER_DATE" >actual && + test_cmp expect actual +' + test_expect_success 'grep with CE_VALID file' ' git update-index --assume-unchanged t/t && rm t/t && -- cgit v1.2.1 From 72fd13f71c18b438ca3e482c126bcbcaa2dac650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 29 Sep 2012 11:41:28 +0700 Subject: revision: add --grep-reflog to filter commits by reflog messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to --author/--committer which filters commits by author and committer header fields. --grep-reflog adds a fake "reflog" header to commit and a grep filter to search on that line. All rules to --author/--committer apply except no timestamp stripping. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 30eaa9a54b..3a5d0fd770 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -546,6 +546,32 @@ test_expect_success 'log grep (6)' ' test_cmp expect actual ' +test_expect_success 'log grep (7)' ' + git log -g --grep-reflog="commit: third" --pretty=tformat:%s >actual && + echo third >expect && + test_cmp expect actual +' + +test_expect_success 'log grep (8)' ' + git log -g --grep-reflog="commit: third" --grep-reflog="commit: second" --pretty=tformat:%s >actual && + { + echo third && echo second + } >expect && + test_cmp expect actual +' + +test_expect_success 'log grep (9)' ' + git log -g --grep-reflog="commit: third" --author="Thor" --pretty=tformat:%s >actual && + echo third >expect && + test_cmp expect actual +' + +test_expect_success 'log grep (9)' ' + git log -g --grep-reflog="commit: third" --author="non-existant" --pretty=tformat:%s >actual && + : >expect && + test_cmp expect actual +' + test_expect_success 'log with multiple --grep uses union' ' git log --grep=i --grep=r --format=%s >actual && { -- cgit v1.2.1 From baa6378ff2106738c74213280904507d0ed8129c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 29 Sep 2012 11:59:52 -0700 Subject: log --grep-reflog: reject the option without -g Signed-off-by: Junio C Hamano --- t/t7810-grep.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 't/t7810-grep.sh') diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 3a5d0fd770..f698001c99 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -572,6 +572,10 @@ test_expect_success 'log grep (9)' ' test_cmp expect actual ' +test_expect_success 'log --grep-reflog can only be used under -g' ' + test_must_fail git log --grep-reflog="commit: third" +' + test_expect_success 'log with multiple --grep uses union' ' git log --grep=i --grep=r --format=%s >actual && { -- cgit v1.2.1