git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: markus.heidelberg@web.de,
	"René Scharfe" <rene.scharfe@lsrfire.ath.cx>,
	git@vger.kernel.org
Subject: Re: [PATCH 1/2] handle color.ui at a central place
Date: Sat, 24 Jan 2009 12:26:50 -0800	[thread overview]
Message-ID: <7vvds4movp.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20090124191700.GA17935@coredump.intra.peff.net> (Jeff King's message of "Sat, 24 Jan 2009 14:17:01 -0500")

Jeff King <peff@peff.net> writes:

> On Sat, Jan 24, 2009 at 10:36:24AM -0800, Junio C Hamano wrote:
> ...
>> You did not find the breakage in format-patch either to begin with; so
>> your not finding does not give us much confidence that there is no other
>> breakage, does it?
>> 
>> Grumble...
>
> Sadly, this is an area that is not covered very well in the tests
> (partially, I think, because it is "just" output which we tend to
> neglect, and partially because the isatty() stuff is hard to test with
> our harness). So I don't think it's _entirely_ Markus' fault.

Oh, don't get me wrong.  I am not interested in finding whose fault it
was.  I was just stating the fact that one person not finding a breakage
does not mean much as an assurance.

It is actually not trivial to test this breakage in our test suite.
Before committing 9383af1 (Revert previous two commits, 2009-01-23), I
spent about 20 minutes trying to come up with a test to expose the
breakage in an acceptable way.  A test that assumes that it is run with a
controlling terminal is relatively easy to write, but I couldn't come up
with a test that would have triggered even when the tests were run without
a tty (for gory details, see git_config_colorbool() and how stdout_is_tty
is used).

Here is the "relatively easy" but an unacceptable one.

diff --git c/t/t4014-format-patch.sh w/t/t4014-format-patch.sh
index 9d99dc2..609946a 100755
--- c/t/t4014-format-patch.sh
+++ w/t/t4014-format-patch.sh
@@ -255,4 +255,10 @@ test_expect_success 'format-patch respects -U' '
 
 '
 
+test_expect_success 'format-patch is colorless even with color.ui = auto' '
+	git config color.ui auto &&
+	TERM=ansi git format-patch -1 >/dev/tty &&
+	grep "^+5$" 0001-foo.patch
+'
+
 test_done

Points that makes the above patch unacceptable are:

 (1) It hardcodes 0001-foo.patch.  You could try doing these:

     (1.1) patchname=$( ... git format-patch -1) && grep ... <"$patchname"
     (1.2) git format-patch -1 --stdout >patchfile && grep ... <patchfile

     but they won't work, because "color.ui = auto" will not color unless
     the standard output is a tty, and TERM is better than "dumb".

 (2) It would not trigger if /dev/tty cannot be opened for writing.

     

  reply	other threads:[~2009-01-24 20:28 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16 15:06 [PATCH 3/3] Adds a #!bash to the top of bash completions so that editors can recognize, it as a bash script. Also adds a few simple comments above commands that, take arguments. The comments are meant to remind editors of potential, problems that Baz
2009-01-17  1:40 ` Jeff King
2009-01-17 12:37   ` Markus Heidelberg
2009-01-17 15:21     ` Jeff King
2009-01-17 15:32       ` [PATCH 1/2] color: make it easier for non-config to parse color specs Jeff King
2009-01-18 17:10         ` René Scharfe
2009-01-18 17:28           ` Jeff King
2009-01-18 17:36             ` Jeff King
2009-01-18 17:45             ` René Scharfe
2009-01-18 18:06               ` Jeff King
2009-01-17 15:38       ` [PATCH 2/2] expand --pretty=format color options Jeff King
2009-01-18 17:13         ` René Scharfe
2009-01-18 17:37           ` Jeff King
2009-01-18 19:43             ` Jeff King
2009-01-18 19:53               ` Jeff King
2009-01-18 20:37                 ` [PATCH 1/2] handle color.ui at a central place Markus Heidelberg
2009-01-18 20:39                   ` [PATCH 2/2] move the color variables to color.c Markus Heidelberg
2009-01-20  4:04                   ` [PATCH 1/2] handle color.ui at a central place Jeff King
2009-01-21 22:35                     ` Markus Heidelberg
2009-01-22  0:00                       ` Jeff King
2009-01-22  0:13                         ` Markus Heidelberg
2009-01-23  6:13                           ` Junio C Hamano
2009-01-24 11:28                             ` Markus Heidelberg
2009-01-24 14:14                               ` Johannes Schindelin
2009-01-24 14:23                                 ` Markus Heidelberg
2009-01-24 18:36                               ` Junio C Hamano
2009-01-24 19:17                                 ` Jeff King
2009-01-24 20:26                                   ` Junio C Hamano [this message]
2009-01-24 20:45                                     ` Jeff King
2009-01-25 14:15                                 ` Markus Heidelberg
2009-01-19 23:10                 ` [PATCH 2/2] expand --pretty=format color options Junio C Hamano
2009-01-20  4:06                   ` Jeff King
2009-01-20 10:27                     ` Johannes Schindelin
2009-01-20 10:36                       ` Johannes Schindelin
2009-01-20 14:23                         ` Jeff King
2009-01-20 14:58                           ` Johannes Schindelin
2009-01-20 19:21                             ` Jeff King
2009-01-17 15:39       ` Cyellow, was Re: [a way-too-long line] Johannes Schindelin
2009-01-17 15:40         ` Jeff King
2009-01-17 15:46           ` Johannes Schindelin

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=7vvds4movp.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=markus.heidelberg@web.de \
    --cc=peff@peff.net \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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).