git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Bugfix: grep: Do not colorize output when -O is set

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 2, 2010, 19:21 UTC
Message-ID
<20100702192102.GA6585@burratino>
In-Reply-To
<1278064941-30689-1-git-send-email-ayiehere@gmail.com>
Hi Nazri,
Nazri Ramliy wrote:
> When color.ui is set to auto, "git grep -Ovi foo" breaks due to the
> presence of color escape sequences.

I tried the following test without your patch, and it seemed to pass without trouble. What am I doing wrong?

diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
index c110441..d47c054 100755
--- a/t/t7811-grep-open.sh
+++ b/t/t7811-grep-open.sh
@@ -125,6 +125,24 @@ test_expect_success 'modified file' '
 	test_cmp empty out
 '
 
+test_expect_success 'copes with color.ui' '
+	rm -f actual &&
+	echo grep.h >expect &&
+	git config color.ui always &&
+	test_when_finished "git config --unset color.ui" &&
+	git grep -O'\''printf "%s\n" >actual'\'' GREP_AND &&
+	test_cmp expect actual
+'
+
+test_expect_success 'copes with color.grep' '
+	rm -f actual &&
+	echo grep.h >expect &&
+	git config color.grep always &&
+	test_when_finished "git config --unset color.grep" &&
+	git grep -O'\''printf "%s\n" >actual'\'' GREP_AND &&
+	test_cmp expect actual
+'
+
 test_expect_success 'run from subdir' '
 	rm -f actual &&
 	echo grep.c >expect &&
Previous: René ScharfeNext: Nazri Ramliy
Message 5 of 11 in “Bugfix: grep: Do not colorize output when -O is set”
  1. Bugfix: grep: Do not colorize output when -O is setNazri Ramliy, Jul 2, 2010
  2. René ScharfeJul 2, 2010
  3. Jonathan NiederJul 6, 2010
  4. René ScharfeJul 6, 2010
  5. Jonathan NiederJul 2, 2010
  6. Nazri RamliyJul 3, 2010
  7. grep -O: Do not pass color sequences as filenames to pagerJonathan Nieder, Jul 3, 2010
  8. Jakub NarebskiJul 3, 2010
  9. t/README: document more test helpersJonathan Nieder, Jul 6, 2010
  10. Ævar Arnfjörð BjarmasonJul 6, 2010
  11. Junio C HamanoJul 7, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.