git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] doc: explain the use of color.pager
@ 2021-05-19  9:17 Jeff King
  2021-05-19 10:41 ` Felipe Contreras
  2021-05-19 19:53 ` Jonathan Nieder
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff King @ 2021-05-19  9:17 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Felipe Contreras, Ævar Arnfjörð Bjarmason

The current documentation for color.pager is technically correct, but
slightly misleading and doesn't really clarify the purpose of the
variable. As explained in the original thread which added it:

  https://lore.kernel.org/git/E1G6zPH-00062L-Je@moooo.ath.cx/

the point is deal with pagers that don't understand colors. And hence it
being set to "true" is necessary for colorizing output to the pager, but
not sufficient by itself (you must also have enabled one of the other
color options, though note that these are set to "auto" by default these
days).

Signed-off-by: Jeff King <peff@peff.net>
---
Just a loose end from:

  https://lore.kernel.org/git/xmqqlf8c2k2y.fsf@gitster.g/

that I think is worth tying up before we forget.

 Documentation/config/color.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt
index d5daacb13a..e05d520a86 100644
--- a/Documentation/config/color.txt
+++ b/Documentation/config/color.txt
@@ -127,8 +127,9 @@ color.interactive.<slot>::
 	interactive commands.
 
 color.pager::
-	A boolean to enable/disable colored output when the pager is in
-	use (default is true).
+	A boolean to specify whether `auto` color modes should colorize
+	output going to the pager. Defaults to true; set this to false
+	if your pager does not understand ANSI color codes.
 
 color.push::
 	A boolean to enable/disable color in push errors. May be set to
-- 
2.32.0.rc0.424.g95d3bde94f

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH] doc: explain the use of color.pager
  2021-05-19  9:17 [PATCH] doc: explain the use of color.pager Jeff King
@ 2021-05-19 10:41 ` Felipe Contreras
  2021-05-19 19:53 ` Jonathan Nieder
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2021-05-19 10:41 UTC (permalink / raw)
  To: Jeff King, Junio C Hamano
  Cc: git, Felipe Contreras, Ævar Arnfjörð Bjarmason

Jeff King wrote:
> diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt
> index d5daacb13a..e05d520a86 100644
> --- a/Documentation/config/color.txt
> +++ b/Documentation/config/color.txt
> @@ -127,8 +127,9 @@ color.interactive.<slot>::
>  	interactive commands.
>  
>  color.pager::
> -	A boolean to enable/disable colored output when the pager is in
> -	use (default is true).
> +	A boolean to specify whether `auto` color modes should colorize
> +	output going to the pager. Defaults to true; set this to false
> +	if your pager does not understand ANSI color codes.

This sounds correct to me, short, and complete. I like it.

Acked-by: Felipe Contreras <felipe.contreras@gmail.com>

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-19  9:17 [PATCH] doc: explain the use of color.pager Jeff King
  2021-05-19 10:41 ` Felipe Contreras
@ 2021-05-19 19:53 ` Jonathan Nieder
  2021-05-19 20:39   ` Felipe Contreras
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Jonathan Nieder @ 2021-05-19 19:53 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, git, Felipe Contreras,
	Ævar Arnfjörð Bjarmason

Jeff King wrote:

> The current documentation for color.pager is technically correct, but
> slightly misleading and doesn't really clarify the purpose of the
> variable. As explained in the original thread which added it:
>
>   https://lore.kernel.org/git/E1G6zPH-00062L-Je@moooo.ath.cx/
>
> the point is deal with pagers that don't understand colors.

Missing "to" before "deal".  More importantly, I think I'd find a
reference to the commit or a quotation from the affected user more
helpful than a reference to the mailing list archive, since that would
make this a bit more self-contained.  (Especially since I think this
is un-subtle enough that chasing through the mailing list thread
doesn't add much to my life. :))

[...]
> --- a/Documentation/config/color.txt
> +++ b/Documentation/config/color.txt
> @@ -127,8 +127,9 @@ color.interactive.<slot>::
>  	interactive commands.
>  
>  color.pager::
> -	A boolean to enable/disable colored output when the pager is in
> -	use (default is true).
> +	A boolean to specify whether `auto` color modes should colorize
> +	output going to the pager. Defaults to true; set this to false
> +	if your pager does not understand ANSI color codes.

I quite like the "set this to false if your pager does not understand
ANSI color codes" part --- short and to the point.

The sentence before takes me long enough to understand that I don't
think we've gotten the wording right yet.  Before I suggest some
wording, let's make sure I understand the behavior correctly:

- unlike other color.* settings, this can only be "true" or "false".
  It cannot be "auto".

- in other color.* settings, "auto" means "colors are used only when
  stderr goes to a terminal".  A pager typically ultimately writes to
  a terminal, but (1) it's not guaranteed to (e.g., xless writes to
  its own window instead) and (2) more importantly for us, it's not
  guaranteed to write terminal escapes as is.

- so this setting can be used to answer "for the sake of evaluating
  color settings, should we treat output that is going to a pager as
  going to a terminal?"

If I understood correctly, how about some text like the following?

	A boolean to specify whether `auto` color modes should colorize
	output going to a pager, in addition to their behavior of
	colorizing output going to a terminal. Defaults to true; [etc]

Side note, not about this patch: we treat pager.color as a synonym for
color.pager.  Is that something we want to document, or is that an
instance of being extra friendly when the user makes a typo?

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-19 19:53 ` Jonathan Nieder
@ 2021-05-19 20:39   ` Felipe Contreras
  2021-05-19 22:47   ` Junio C Hamano
  2021-05-20  6:36   ` Junio C Hamano
  2 siblings, 0 replies; 8+ messages in thread
From: Felipe Contreras @ 2021-05-19 20:39 UTC (permalink / raw)
  To: Jonathan Nieder, Jeff King
  Cc: Junio C Hamano, git, Felipe Contreras,
	Ævar Arnfjörð Bjarmason

Jonathan Nieder wrote:

> More importantly, I think I'd find a reference to the commit or a
> quotation from the affected user more helpful than a reference to the
> mailing list archive, since that would make this a bit more
> self-contained.

And for me it's the opposite; I find what one user found at one point in
time long ago not particularly important. At best it's a footnote.

> [...]
> > --- a/Documentation/config/color.txt
> > +++ b/Documentation/config/color.txt
> > @@ -127,8 +127,9 @@ color.interactive.<slot>::
> >  	interactive commands.
> >  
> >  color.pager::
> > -	A boolean to enable/disable colored output when the pager is in
> > -	use (default is true).
> > +	A boolean to specify whether `auto` color modes should colorize
> > +	output going to the pager. Defaults to true; set this to false
> > +	if your pager does not understand ANSI color codes.
> 
> I quite like the "set this to false if your pager does not understand
> ANSI color codes" part --- short and to the point.
> 
> The sentence before takes me long enough to understand that I don't
> think we've gotten the wording right yet.  Before I suggest some
> wording, let's make sure I understand the behavior correctly:
> 
> - unlike other color.* settings, this can only be "true" or "false".
>   It cannot be "auto".
> 
> - in other color.* settings, "auto" means "colors are used only when
>   stderr goes to a terminal".  A pager typically ultimately writes to
>   a terminal, but (1) it's not guaranteed to (e.g., xless writes to
>   its own window instead) and (2) more importantly for us, it's not
>   guaranteed to write terminal escapes as is.
> 
> - so this setting can be used to answer "for the sake of evaluating
>   color settings, should we treat output that is going to a pager as
>   going to a terminal?"

Correct.

> If I understood correctly, how about some text like the following?
> 
> 	A boolean to specify whether `auto` color modes should colorize
> 	output going to a pager, in addition to their behavior of
> 	colorizing output going to a terminal.

The "in adittion" part is unnecessary. You don't say "the rest of git's
behavior remains unafffected" on every single configuration. That is
obvious.

We are specifying what happens when output is going to a pager, that's
it.

Everything else--including what happens when the output going to
different programs--it not relevant.

In addition, as far as I can recall there are no commands that send
output both to a pager and to a terminal.

> Side note, not about this patch: we treat pager.color as a synonym for
> color.pager.  Is that something we want to document, or is that an
> instance of being extra friendly when the user makes a typo?

I suspect pager.color is a remnant from an ancient suboptimal name choice.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-19 19:53 ` Jonathan Nieder
  2021-05-19 20:39   ` Felipe Contreras
@ 2021-05-19 22:47   ` Junio C Hamano
  2021-05-20  6:36   ` Junio C Hamano
  2 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2021-05-19 22:47 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Jeff King, git, Felipe Contreras, Ævar Arnfjörð Bjarmason

Jonathan Nieder <jrnieder@gmail.com> writes:

> Side note, not about this patch: we treat pager.color as a synonym for
> color.pager.  Is that something we want to document, or is that an
> instance of being extra friendly when the user makes a typo?

IIUC, this is the same historical wart that comes from the same
place as diff.color that existed before color.<cmd> wanted to be the
way forward.  We do not break existing configuration files by
starting to suddenly reject diff.color or pager.color, but we do not
encourage new uses by not advertising them.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-19 19:53 ` Jonathan Nieder
  2021-05-19 20:39   ` Felipe Contreras
  2021-05-19 22:47   ` Junio C Hamano
@ 2021-05-20  6:36   ` Junio C Hamano
  2021-05-20  8:33     ` Jeff King
  2 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2021-05-20  6:36 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: Jeff King, git, Felipe Contreras, Ævar Arnfjörð Bjarmason

Jonathan Nieder <jrnieder@gmail.com> writes:

>> The current documentation for color.pager is technically correct, but
>> slightly misleading and doesn't really clarify the purpose of the
>> variable. As explained in the original thread which added it:
>>
>>   https://lore.kernel.org/git/E1G6zPH-00062L-Je@moooo.ath.cx/
>>
>> the point is deal with pagers that don't understand colors.
>
> Missing "to" before "deal".

Will locally amend.

> More importantly, I think I'd find a
> reference to the commit or a quotation from the affected user more
> helpful than a reference to the mailing list archive, since that would
> make this a bit more self-contained.

The original commit and its log message we ended up with did not
explain the motivation behind well enough.

The motivation from the original thread:

      When I use a pager that escapes the escape character or highlights the
      content itself the output of git diff without the pager should have
      colors but not with the pager.  For example using git diff with a
      pathspec is quite short most of the time.  For git diff I have to
      enable paging manually and run git diff | $PAGER usually but git log
      uses the pager automatically and should not use colors with it.

can be quoted as a whole, but "the point is to deal with ..." is a
succinct summary that is good enough for the purpose of this commit,
I would think.

>> +	A boolean to specify whether `auto` color modes should colorize
>> +	output going to the pager. Defaults to true; set this to false
>> +	if your pager does not understand ANSI color codes.
>
> I quite like the "set this to false if your pager does not understand
> ANSI color codes" part --- short and to the point.
>
> The sentence before takes me long enough to understand that I don't
> think we've gotten the wording right yet.  Before I suggest some
> wording, let's make sure I understand the behavior correctly:
>
> - unlike other color.* settings, this can only be "true" or "false".
>   It cannot be "auto".

Correct.

> - in other color.* settings, "auto" means "colors are used only when
>   stderr goes to a terminal".  A pager typically ultimately writes to
>   a terminal, but (1) it's not guaranteed to (e.g., xless writes to
>   its own window instead) and (2) more importantly for us, it's not
>   guaranteed to write terminal escapes as is.

Correct---color.pager is about telling Git about the pager's capability.

> - so this setting can be used to answer "for the sake of evaluating
>   color settings, should we treat output that is going to a pager as
>   going to a terminal?"

I am not sure if that is the easiest-to-explain way to view it.
It's more like "color.diff says 'auto', so we'd color it when the
output is going to tty and the terminal is not dumb.  We'd also
color it when our output is not directly going to tty (because we
are writing to a pipe whose other end is being read by the pager)
but we know we are talking to a pager, BUT the pager may not be able
to handle coloured output correctly---so we need a way to say "no,
even though our output goes to the pager, we cannot colour the
output".

> If I understood correctly, how about some text like the following?
>
> 	A boolean to specify whether `auto` color modes should colorize
> 	output going to a pager, in addition to their behavior of
> 	colorizing output going to a terminal. Defaults to true; [etc]

The variable has no control over what happens to output that
directly goes to a terminal, so while the additional phrase might
not be technically wrong per-se, I do not see why this is more clear
than the original.

So, in short, I think it would be sufficient to amend the proposed
log message with s/deal with/to deal with/ and nothing else.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-20  6:36   ` Junio C Hamano
@ 2021-05-20  8:33     ` Jeff King
  2021-05-20 15:05       ` Jonathan Nieder
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2021-05-20  8:33 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Jonathan Nieder, git, Felipe Contreras,
	Ævar Arnfjörð Bjarmason

On Thu, May 20, 2021 at 03:36:59PM +0900, Junio C Hamano wrote:

> > More importantly, I think I'd find a
> > reference to the commit or a quotation from the affected user more
> > helpful than a reference to the mailing list archive, since that would
> > make this a bit more self-contained.
> 
> The original commit and its log message we ended up with did not
> explain the motivation behind well enough.
> 
> The motivation from the original thread:
> 
>       When I use a pager that escapes the escape character or highlights the
>       content itself the output of git diff without the pager should have
>       colors but not with the pager.  For example using git diff with a
>       pathspec is quite short most of the time.  For git diff I have to
>       enable paging manually and run git diff | $PAGER usually but git log
>       uses the pager automatically and should not use colors with it.
> 
> can be quoted as a whole, but "the point is to deal with ..." is a
> succinct summary that is good enough for the purpose of this commit,
> I would think.

Thanks, I was just preparing a near-identical response.

I do think it's an important principle in general to summarize the
content of things we link to. It's just that the summary in this case
was so short that it was easy to look past. :)

> > If I understood correctly, how about some text like the following?
> >
> > 	A boolean to specify whether `auto` color modes should colorize
> > 	output going to a pager, in addition to their behavior of
> > 	colorizing output going to a terminal. Defaults to true; [etc]
> 
> The variable has no control over what happens to output that
> directly goes to a terminal, so while the additional phrase might
> not be technically wrong per-se, I do not see why this is more clear
> than the original.

Unsurprisingly, that's my opinion, too. While writing it, I actually did
try some longer explanations to explain from the ground up, but I
worried it was distracting from the main point of this variable. E.g.,
something like:

  When color mode options (e.g., `color.ui`) are set to `auto`, Git by
  default will enable color when the output is going to a terminal or to
  a pager (since the pager itself is outputting to a terminal). This is
  a problem if your pager doesn't faithfully relay the color codes to
  the terminal. You can set this boolean to `false` to disable color
  when output is going to a terminal.

> So, in short, I think it would be sufficient to amend the proposed
> log message with s/deal with/to deal with/ and nothing else.

I'm happy with that.

-Peff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: explain the use of color.pager
  2021-05-20  8:33     ` Jeff King
@ 2021-05-20 15:05       ` Jonathan Nieder
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Nieder @ 2021-05-20 15:05 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, git, Felipe Contreras,
	Ævar Arnfjörð Bjarmason

Hi,

Jeff King wrote:
> On Thu, May 20, 2021 at 03:36:59PM +0900, Junio C Hamano wrote:

>> The original commit and its log message we ended up with did not
>> explain the motivation behind well enough.
>>
>> The motivation from the original thread:
>>
>>       When I use a pager that escapes the escape character or highlights the
>>       content itself the output of git diff without the pager should have
>>       colors but not with the pager.  For example using git diff with a
>>       pathspec is quite short most of the time.  For git diff I have to
>>       enable paging manually and run git diff | $PAGER usually but git log
>>       uses the pager automatically and should not use colors with it.
>>
>> can be quoted as a whole, but "the point is to deal with ..." is a
>> succinct summary that is good enough for the purpose of this commit,
>> I would think.
>
> Thanks, I was just preparing a near-identical response.
>
> I do think it's an important principle in general to summarize the
> content of things we link to. It's just that the summary in this case
> was so short that it was easy to look past. :)

I was making a different point: that the summary is so good that the
link is not even needed (or that if you are just trying to cite your
sources, it should be a footnote).  The current proposed commit
message makes the link prominent, which tells the reader that reading
the thread is a good use of their time, when in this example it isn't.

[...]
>   When color mode options (e.g., `color.ui`) are set to `auto`, Git by
>   default will enable color when the output is going to a terminal or to
>   a pager (since the pager itself is outputting to a terminal). This is
>   a problem if your pager doesn't faithfully relay the color codes to
>   the terminal. You can set this boolean to `false` to disable color
>   when output is going to a terminal.

Oh!  FWIW, I like that and don't think it's overkill.

> On Thu, May 20, 2021 at 03:36:59PM +0900, Junio C Hamano wrote:

>> So, in short, I think it would be sufficient to amend the proposed
>> log message with s/deal with/to deal with/ and nothing else.
>
> I'm happy with that.

Yes, the proposed patch is an improvement on the status quo, so I'd
rather that it land as-is than not land at all.  That said, the
resulting text is still confusing.  It can be easy to forget how much
context we're assuming when we read it ourselves; the proposed text
still makes an uninitiated reader go "huh?" in a way that the "When
color mode options" example above does not.

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-20 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  9:17 [PATCH] doc: explain the use of color.pager Jeff King
2021-05-19 10:41 ` Felipe Contreras
2021-05-19 19:53 ` Jonathan Nieder
2021-05-19 20:39   ` Felipe Contreras
2021-05-19 22:47   ` Junio C Hamano
2021-05-20  6:36   ` Junio C Hamano
2021-05-20  8:33     ` Jeff King
2021-05-20 15:05       ` Jonathan Nieder

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).