git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Bert Wesarg <bert.wesarg@googlemail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Thiago dos Santos Alvest" <hiago.salves@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] grep: add known breakage of coloring when using extended patterns
Date: Mon, 02 May 2011 19:14:26 +0200	[thread overview]
Message-ID: <4DBEE672.5070707@lsrfire.ath.cx> (raw)
In-Reply-To: <328649cbd9fe7f2ee5f43d1e860d712f4204bdc5.1304333975.git.bert.wesarg@googlemail.com>

Am 02.05.2011 13:35, schrieb Bert Wesarg:
> The coloring code does not respect the extended pattern format, expose
> this with an known breakage test.
>
> Signed-off-by: Bert Wesarg<bert.wesarg@googlemail.com>
> ---
>   t/t7812-grep-color.sh |   25 +++++++++++++++++++++++++
>   1 files changed, 25 insertions(+), 0 deletions(-)
>   create mode 100755 t/t7812-grep-color.sh
>
> diff --git a/t/t7812-grep-color.sh b/t/t7812-grep-color.sh
> new file mode 100755
> index 0000000..2cffff3
> --- /dev/null
> +++ b/t/t7812-grep-color.sh
> @@ -0,0 +1,25 @@
> +#!/bin/sh
> +
> +test_description='git grep --color
> +'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup' '
> +	test_commit initial input "foo bar baz
> +bar baz
> +"
> +'
> +
> +cat>expected<<EOF
> +input<CYAN>:<RESET><BOLD;RED>foo<RESET>  bar baz
> +EOF
> +
> +
> +test_expect_failure 'grep coloring does not honor boolean algebra' '
> +	git grep --color -e foo --or \( -e bar --and --not -e baz \) |
> +		test_decode_color>actual
> +    test_cmp expected actual
> +'
> +
> +test_done

The current code highlights the given search terms ("atoms").  You 
expect the matching part of a line to be highlighted instead.  Another 
example with differing results between the two ways is this:

	$ git grep -v -e foo --and -e bar

The first one was easy to implement and useful already.  I wonder how to 
implement the second one (I couldn't think of an easy way back then) and 
also if we really prefer it to the current behaviour in the first place.

The twisted logic that convinced me to forget about the issue goes like 
this: Even by giving negative search terms, the user is expressing a 
certain value of interest in them; highlighting these atoms even in 
lines which were not matched by them is a courtesy.

René

  parent reply	other threads:[~2011-05-02 17:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-02 11:35 [PATCH] grep: add known breakage of coloring when using extended patterns Bert Wesarg
2011-05-02 11:41 ` Johannes Sixt
2011-05-02 11:48   ` Bert Wesarg
2011-05-02 17:14 ` René Scharfe [this message]
2011-05-02 17:37   ` Junio C Hamano
2011-05-02 21:07     ` René Scharfe
2011-05-02 22:04       ` Junio C Hamano
2011-05-03 17:36         ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DBEE672.5070707@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hiago.salves@gmail.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).