All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
@ 2021-12-01  5:32 Eric Sunshine
  2021-12-01  8:33 ` Fabian Stelzer
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Eric Sunshine @ 2021-12-01  5:32 UTC (permalink / raw)
  To: git
  Cc: Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein, Eric Sunshine

It has long been practice in this project for a command to emit its
primary output to stdout so that it can be captured to a file or sent
down a pipe, and to emit "chatty" messages (such as those reporting
progress) to stderr so that they don't interfere with the primary
output. However, this idiomatic Unix practice is not necessarily
universally understood and may be at odds with other schools of thought,
such as the somewhat common one that only error messages should go to
stderr, and all other messages to stdout. Let's help newcomers by
documenting how stdout and stderr are used on this project.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 Documentation/CodingGuidelines | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 711cb9171e..44dd178dc9 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -499,6 +499,32 @@ For Python scripts:
  - Where required libraries do not restrict us to Python 2, we try to
    also be compatible with Python 3.1 and later.
 
+
+Program Output
+
+ We make a distinction between a command's primary output and output
+ which is merely chatty feedback (for instance, status messages,
+ running transcript, or progress display), as well as error messages.
+ Roughly speaking, a command's primary output is that which one might
+ want to capture to a file or send down a pipe; its chatty output
+ should not interfere with those use-cases.
+
+ As such, primary output should be sent to the standard output stream
+ (stdout), and chatty output should be sent to the standard error
+ stream (stderr). Examples of commands which produce primary output
+ include `git log`, `git show`, and `git branch --list` which generate
+ output on the stdout stream.
+
+ Not all commands have primary output; this is often true of commands
+ whose main function is to perform an action. Some action commands are
+ silent, whereas others are chatty. An example of a chatty action
+ commands is `git clone` with its "Cloning into '<path>'..." and
+ "Checking connectivity..." status messages which it sends to the
+ stderr stream.
+
+ Error messages are always sent to the stderr stream.
+
+
 Error Messages
 
  - Do not end error messages with a full stop.
-- 
2.34.1.75.gabe6bb3905


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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01  5:32 [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr Eric Sunshine
@ 2021-12-01  8:33 ` Fabian Stelzer
  2021-12-01 13:50   ` Eric Sunshine
  2021-12-01 19:42 ` Jeff King
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Fabian Stelzer @ 2021-12-01  8:33 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: git, Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On 01.12.2021 00:32, Eric Sunshine wrote:
>It has long been practice in this project for a command to emit its
>primary output to stdout so that it can be captured to a file or sent
>down a pipe, and to emit "chatty" messages (such as those reporting
>progress) to stderr so that they don't interfere with the primary
>output. However, this idiomatic Unix practice is not necessarily
>universally understood and may be at odds with other schools of thought,
>such as the somewhat common one that only error messages should go to
>stderr, and all other messages to stdout. Let's help newcomers by
>documenting how stdout and stderr are used on this project.
>
>Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
>---
> Documentation/CodingGuidelines | 26 ++++++++++++++++++++++++++
> 1 file changed, 26 insertions(+)
>
>diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
>index 711cb9171e..44dd178dc9 100644
>--- a/Documentation/CodingGuidelines
>+++ b/Documentation/CodingGuidelines
>@@ -499,6 +499,32 @@ For Python scripts:
>  - Where required libraries do not restrict us to Python 2, we try to
>    also be compatible with Python 3.1 and later.
>
>+
>+Program Output
>+
>+ We make a distinction between a command's primary output and output
>+ which is merely chatty feedback (for instance, status messages,
>+ running transcript, or progress display), as well as error messages.
>+ Roughly speaking, a command's primary output is that which one might
>+ want to capture to a file or send down a pipe; its chatty output
>+ should not interfere with those use-cases.
>+
>+ As such, primary output should be sent to the standard output stream
>+ (stdout), and chatty output should be sent to the standard error
>+ stream (stderr). Examples of commands which produce primary output
>+ include `git log`, `git show`, and `git branch --list` which generate
>+ output on the stdout stream.
>+
>+ Not all commands have primary output; this is often true of commands
>+ whose main function is to perform an action. Some action commands are
>+ silent, whereas others are chatty. An example of a chatty action
>+ commands is `git clone` with its "Cloning into '<path>'..." and
>+ "Checking connectivity..." status messages which it sends to the
>+ stderr stream.
>+
>+ Error messages are always sent to the stderr stream.
>+

This is not necessarily true in the context of the tests.
We just spoke about this in: 
https://lore.kernel.org/git/211130.86wnkpd6ou.gmgdl@evledraar.gmail.com/T/#u

I don't think it necessary to bloat this explanation with the test details.  
But mentioning it as an exception would be good.

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01  8:33 ` Fabian Stelzer
@ 2021-12-01 13:50   ` Eric Sunshine
  2021-12-01 15:14     ` Fabian Stelzer
  2021-12-01 21:35     ` Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Sunshine @ 2021-12-01 13:50 UTC (permalink / raw)
  To: Fabian Stelzer
  Cc: Git List, Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On Wed, Dec 1, 2021 at 3:33 AM Fabian Stelzer <fs@gigacodes.de> wrote:
> On 01.12.2021 00:32, Eric Sunshine wrote:
> >+ We make a distinction between a command's primary output and output
> >+ which is merely chatty feedback (for instance, status messages,
> >+ running transcript, or progress display), as well as error messages.
> >+ Roughly speaking, a command's primary output is that which one might
> >+ want to capture to a file or send down a pipe; its chatty output
> >+ should not interfere with those use-cases.
> >+
> >+ As such, primary output should be sent to the standard output stream
> >+ (stdout), and chatty output should be sent to the standard error
> >+ stream (stderr). Examples of commands which produce primary output
> >+ include `git log`, `git show`, and `git branch --list` which generate
> >+ output on the stdout stream.
> >+
> >+ Not all commands have primary output; this is often true of commands
> >+ whose main function is to perform an action. Some action commands are
> >+ silent, whereas others are chatty. An example of a chatty action
> >+ commands is `git clone` with its "Cloning into '<path>'..." and
> >+ "Checking connectivity..." status messages which it sends to the
> >+ stderr stream.
> >+
> >+ Error messages are always sent to the stderr stream.
>
> This is not necessarily true in the context of the tests.
> We just spoke about this in:
> https://lore.kernel.org/git/211130.86wnkpd6ou.gmgdl@evledraar.gmail.com/T/#u
>
> I don't think it necessary to bloat this explanation with the test details.
> But mentioning it as an exception would be good.

Yep, I tried to be clear about that by repeatedly stating that
_command_ output should follow this guideline, where "command" means
"Git command". I strongly considered writing "Git command" to be
perfectly clear, but figured reviewers would insist that it was
redundant to mention "Git".

However, I can certainly change these to say "Git command" if you
think it would make the intent clearer, and can update the final point
to say:

    Error messages from Git commands should always
    be sent to the stderr stream.

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01 13:50   ` Eric Sunshine
@ 2021-12-01 15:14     ` Fabian Stelzer
  2021-12-01 21:35     ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Fabian Stelzer @ 2021-12-01 15:14 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Git List, Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On 01.12.2021 08:50, Eric Sunshine wrote:
>On Wed, Dec 1, 2021 at 3:33 AM Fabian Stelzer <fs@gigacodes.de> wrote:
>> On 01.12.2021 00:32, Eric Sunshine wrote:
>> >+ We make a distinction between a command's primary output and output
>> >+ which is merely chatty feedback (for instance, status messages,
>> >+ running transcript, or progress display), as well as error messages.
>> >+ Roughly speaking, a command's primary output is that which one might
>> >+ want to capture to a file or send down a pipe; its chatty output
>> >+ should not interfere with those use-cases.
>> >+
>> >+ As such, primary output should be sent to the standard output stream
>> >+ (stdout), and chatty output should be sent to the standard error
>> >+ stream (stderr). Examples of commands which produce primary output
>> >+ include `git log`, `git show`, and `git branch --list` which generate
>> >+ output on the stdout stream.
>> >+
>> >+ Not all commands have primary output; this is often true of commands
>> >+ whose main function is to perform an action. Some action commands are
>> >+ silent, whereas others are chatty. An example of a chatty action
>> >+ commands is `git clone` with its "Cloning into '<path>'..." and
>> >+ "Checking connectivity..." status messages which it sends to the
>> >+ stderr stream.
>> >+
>> >+ Error messages are always sent to the stderr stream.
>>
>> This is not necessarily true in the context of the tests.
>> We just spoke about this in:
>> https://lore.kernel.org/git/211130.86wnkpd6ou.gmgdl@evledraar.gmail.com/T/#u
>>
>> I don't think it necessary to bloat this explanation with the test details.
>> But mentioning it as an exception would be good.
>
>Yep, I tried to be clear about that by repeatedly stating that
>_command_ output should follow this guideline, where "command" means
>"Git command". I strongly considered writing "Git command" to be
>perfectly clear, but figured reviewers would insist that it was
>redundant to mention "Git".
>
>However, I can certainly change these to say "Git command" if you
>think it would make the intent clearer, and can update the final point
>to say:
>
>    Error messages from Git commands should always
>    be sent to the stderr stream.

Maybe it was just because i was working on test-lib stuff earlier that i did 
not connect `a commands output` to a `git command` but basically understood 
it as all output in git code.
Still, I think your addition to the last sentence is a good idea and won't 
hurt.

Thanks

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01  5:32 [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr Eric Sunshine
  2021-12-01  8:33 ` Fabian Stelzer
@ 2021-12-01 19:42 ` Jeff King
  2021-12-01 20:30   ` Eric Sunshine
  2021-12-01 23:27 ` Philip Oakley
  2021-12-02 22:31 ` [PATCH v2] " Eric Sunshine
  3 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2021-12-01 19:42 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Randall Becker, Baruch Burstein

On Wed, Dec 01, 2021 at 12:32:14AM -0500, Eric Sunshine wrote:

> It has long been practice in this project for a command to emit its
> primary output to stdout so that it can be captured to a file or sent
> down a pipe, and to emit "chatty" messages (such as those reporting
> progress) to stderr so that they don't interfere with the primary
> output. However, this idiomatic Unix practice is not necessarily
> universally understood and may be at odds with other schools of thought,
> such as the somewhat common one that only error messages should go to
> stderr, and all other messages to stdout. Let's help newcomers by
> documenting how stdout and stderr are used on this project.

I agree with everything you wrote here and below, which I think captures
what we want to communicate to folks adding new messages or commands.

I am not quite sure _everyone_ would agree with "this idiomatic Unix
practice" above. It does seem to be a matter of taste (it is just that
what you wrote very much agrees with my taste :) ). And "idiomatic Unix
practice" is probably not to be chatty at all, but I think that has been
changing over the years.

So I'm not sure if your commit message is being nicely assertive about
its taste, or is being uncharitable to people who may have different
tastes (but again, IMHO we should pick a direction and this seems like
the best one to me). :)

-Peff

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01 19:42 ` Jeff King
@ 2021-12-01 20:30   ` Eric Sunshine
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Sunshine @ 2021-12-01 20:30 UTC (permalink / raw)
  To: Jeff King
  Cc: Git List, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Randall Becker, Baruch Burstein

On Wed, Dec 1, 2021 at 2:42 PM Jeff King <peff@peff.net> wrote:
> On Wed, Dec 01, 2021 at 12:32:14AM -0500, Eric Sunshine wrote:
> > It has long been practice in this project for a command to emit its
> > primary output to stdout so that it can be captured to a file or sent
> > down a pipe, and to emit "chatty" messages (such as those reporting
> > progress) to stderr so that they don't interfere with the primary
> > output. However, this idiomatic Unix practice is not necessarily
> > universally understood and may be at odds with other schools of thought,
> > such as the somewhat common one that only error messages should go to
> > stderr, and all other messages to stdout. Let's help newcomers by
> > documenting how stdout and stderr are used on this project.
>
> I agree with everything you wrote here and below, which I think captures
> what we want to communicate to folks adding new messages or commands.
>
> I am not quite sure _everyone_ would agree with "this idiomatic Unix
> practice" above. It does seem to be a matter of taste (it is just that
> what you wrote very much agrees with my taste :) ). And "idiomatic Unix
> practice" is probably not to be chatty at all, but I think that has been
> changing over the years.
>
> So I'm not sure if your commit message is being nicely assertive about
> its taste, or is being uncharitable to people who may have different
> tastes (but again, IMHO we should pick a direction and this seems like
> the best one to me). :)

Thanks for the feedback. I'll tone down the commit message when I
reroll to make the patch text spell out "Git command" explicitly so
that it's less likely to mislead the reader (as it misled Fabian) into
thinking the new guideline applies to all output, including test
output.

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01 13:50   ` Eric Sunshine
  2021-12-01 15:14     ` Fabian Stelzer
@ 2021-12-01 21:35     ` Junio C Hamano
  2021-12-01 21:57       ` Eric Sunshine
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2021-12-01 21:35 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Fabian Stelzer, Git List, Jeff King,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

Eric Sunshine <sunshine@sunshineco.com> writes:

> However, I can certainly change these to say "Git command" if you
> think it would make the intent clearer, and can update the final point
> to say:
>
>     Error messages from Git commands should always
>     be sent to the stderr stream.

In an earlier round, I think there was a version without "should" in
there, but I am sure we have bugs that do not follow the guideline.
The proposed phrasing sounds good to me.

Thanks.

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01 21:35     ` Junio C Hamano
@ 2021-12-01 21:57       ` Eric Sunshine
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Sunshine @ 2021-12-01 21:57 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Fabian Stelzer, Git List, Jeff King,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On Wed, Dec 1, 2021 at 4:36 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > However, I can certainly change these to say "Git command" if you
> > think it would make the intent clearer, and can update the final point
> > to say:
> >
> >     Error messages from Git commands should always
> >     be sent to the stderr stream.
>
> In an earlier round, I think there was a version without "should" in
> there, but I am sure we have bugs that do not follow the guideline.
> The proposed phrasing sounds good to me.

Yes, the addition of "should" was intentional, though not for any
concrete reason (it just felt appropriate). I don't feel strongly
either way.

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01  5:32 [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr Eric Sunshine
  2021-12-01  8:33 ` Fabian Stelzer
  2021-12-01 19:42 ` Jeff King
@ 2021-12-01 23:27 ` Philip Oakley
  2021-12-01 23:56   ` Eric Sunshine
  2021-12-02 22:31 ` [PATCH v2] " Eric Sunshine
  3 siblings, 1 reply; 12+ messages in thread
From: Philip Oakley @ 2021-12-01 23:27 UTC (permalink / raw)
  To: Eric Sunshine, git
  Cc: Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On 01/12/2021 05:32, Eric Sunshine wrote:
> It has long been practice in this project for a command to emit its
> primary output to stdout so that it can be captured to a file or sent
> down a pipe, and to emit "chatty" messages (such as those reporting
> progress) to stderr so that they don't interfere with the primary
> output. However, this idiomatic Unix practice is not necessarily
> universally understood and may be at odds with other schools of thought,
> such as the somewhat common one that only error messages should go to
> stderr, and all other messages to stdout. Let's help newcomers by
> documenting how stdout and stderr are used on this project.
>
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
>  Documentation/CodingGuidelines | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 711cb9171e..44dd178dc9 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -499,6 +499,32 @@ For Python scripts:
>   - Where required libraries do not restrict us to Python 2, we try to
>     also be compatible with Python 3.1 and later.
>  
> +
> +Program Output
> +
> + We make a distinction between a command's primary output and output
> + which is merely chatty feedback (for instance, status messages,
> + running transcript, or progress display), as well as error messages.
> + Roughly speaking, a command's primary output is that which one might
> + want to capture to a file or send down a pipe; its chatty output
> + should not interfere with those use-cases.

Is there a case for commenting on whether chatty output may be
suppressed if not feeding a terminal, or is that mentioned elsewhere? I
often see comments about the isatty() detection.

> +
> + As such, primary output should be sent to the standard output stream
> + (stdout), and chatty output should be sent to the standard error
> + stream (stderr). Examples of commands which produce primary output
> + include `git log`, `git show`, and `git branch --list` which generate
> + output on the stdout stream.
> +
> + Not all commands have primary output; this is often true of commands
> + whose main function is to perform an action. Some action commands are
> + silent, whereas others are chatty. An example of a chatty action
> + commands is `git clone` with its "Cloning into '<path>'..." and
> + "Checking connectivity..." status messages which it sends to the
> + stderr stream.
> +
> + Error messages are always sent to the stderr stream.
> +
> +
>  Error Messages
>  
>   - Do not end error messages with a full stop.
Philip

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

* Re: [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01 23:27 ` Philip Oakley
@ 2021-12-01 23:56   ` Eric Sunshine
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Sunshine @ 2021-12-01 23:56 UTC (permalink / raw)
  To: Philip Oakley
  Cc: Git List, Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein

On Wed, Dec 1, 2021 at 6:27 PM Philip Oakley <philipoakley@iee.email> wrote:
> On 01/12/2021 05:32, Eric Sunshine wrote:
> > +Program Output
> > +
> > + We make a distinction between a command's primary output and output
> > + which is merely chatty feedback (for instance, status messages,
> > + running transcript, or progress display), as well as error messages.
> > + Roughly speaking, a command's primary output is that which one might
> > + want to capture to a file or send down a pipe; its chatty output
> > + should not interfere with those use-cases.
>
> Is there a case for commenting on whether chatty output may be
> suppressed if not feeding a terminal, or is that mentioned elsewhere? I
> often see comments about the isatty() detection.

I don't think I saw any such mention when reading through
CodingGuidelines before composing the new text. That's certainly a
topic which could be addressed, but I don't plan on adding it to this
patch since I don't have any specific idea in mind for how it would be
discussed. However, the new "Program Output" section added by this
patch seems a good place to add that discussion if someone wants to
have a go at it as a separate patch atop this one.

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

* [PATCH v2] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-01  5:32 [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr Eric Sunshine
                   ` (2 preceding siblings ...)
  2021-12-01 23:27 ` Philip Oakley
@ 2021-12-02 22:31 ` Eric Sunshine
  2021-12-02 23:58   ` Jeff King
  3 siblings, 1 reply; 12+ messages in thread
From: Eric Sunshine @ 2021-12-02 22:31 UTC (permalink / raw)
  To: git
  Cc: Jeff King, Junio C Hamano,
	Ævar Arnfjörð Bjarmason, Randall Becker,
	Baruch Burstein, Fabian Stelzer, Philip Oakley, Eric Sunshine

It has long been practice on this project for a command to emit its
primary output to stdout so that it can be captured to a file or sent
down a pipe, and to emit "chatty" messages (such as those reporting
progress) to stderr so that they don't interfere with the primary
output. However, this practice is not necessarily universal; another
common practice is to send only error messages to stderr, and all other
messages to stdout. Therefore, help newcomers out by documenting how
stdout and stderr are used on this project.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---

Changes since v1[*]:

* tone down the commit message (peff)

* replace "command" in the patch body with "Git command" in a few places
  to make it more clear that the new "Program Output" section is
  providing guidelines for how Git commands should behave, as opposed
  to, say, how stdout/stderr should be used in test scripts (fabian)

No interdiff/range-diff since they are too noisy in this case, and the
patch is short enough to easily re-read in its entirety.

[*]: https://lore.kernel.org/git/20211201053214.2902-1-sunshine@sunshineco.com/

 Documentation/CodingGuidelines | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 711cb9171e..0e27b5395d 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -499,6 +499,33 @@ For Python scripts:
  - Where required libraries do not restrict us to Python 2, we try to
    also be compatible with Python 3.1 and later.
 
+
+Program Output
+
+ We make a distinction between a Git command's primary output and
+ output which is merely chatty feedback (for instance, status
+ messages, running transcript, or progress display), as well as error
+ messages. Roughly speaking, a Git command's primary output is that
+ which one might want to capture to a file or send down a pipe; its
+ chatty output should not interfere with these use-cases.
+
+ As such, primary output should be sent to the standard output stream
+ (stdout), and chatty output should be sent to the standard error
+ stream (stderr). Examples of commands which produce primary output
+ include `git log`, `git show`, and `git branch --list` which generate
+ output on the stdout stream.
+
+ Not all Git commands have primary output; this is often true of
+ commands whose main function is to perform an action. Some action
+ commands are silent, whereas others are chatty. An example of a
+ chatty action commands is `git clone` with its "Cloning into
+ '<path>'..." and "Checking connectivity..." status messages which it
+ sends to the stderr stream.
+
+ Error messages from Git commands should always be sent to the stderr
+ stream.
+
+
 Error Messages
 
  - Do not end error messages with a full stop.
-- 
2.34.1.173.g76aa8bc2d0


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

* Re: [PATCH v2] CodingGuidelines: document which output goes to stdout vs. stderr
  2021-12-02 22:31 ` [PATCH v2] " Eric Sunshine
@ 2021-12-02 23:58   ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2021-12-02 23:58 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: git, Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Randall Becker, Baruch Burstein, Fabian Stelzer, Philip Oakley

On Thu, Dec 02, 2021 at 05:31:10PM -0500, Eric Sunshine wrote:

> It has long been practice on this project for a command to emit its
> primary output to stdout so that it can be captured to a file or sent
> down a pipe, and to emit "chatty" messages (such as those reporting
> progress) to stderr so that they don't interfere with the primary
> output. However, this practice is not necessarily universal; another
> common practice is to send only error messages to stderr, and all other
> messages to stdout. Therefore, help newcomers out by documenting how
> stdout and stderr are used on this project.
> 
> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
> ---
> 
> Changes since v1[*]:
> 
> * tone down the commit message (peff)

:) This looks great to me. Thanks for doing it.

-Peff

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

end of thread, other threads:[~2021-12-02 23:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01  5:32 [PATCH] CodingGuidelines: document which output goes to stdout vs. stderr Eric Sunshine
2021-12-01  8:33 ` Fabian Stelzer
2021-12-01 13:50   ` Eric Sunshine
2021-12-01 15:14     ` Fabian Stelzer
2021-12-01 21:35     ` Junio C Hamano
2021-12-01 21:57       ` Eric Sunshine
2021-12-01 19:42 ` Jeff King
2021-12-01 20:30   ` Eric Sunshine
2021-12-01 23:27 ` Philip Oakley
2021-12-01 23:56   ` Eric Sunshine
2021-12-02 22:31 ` [PATCH v2] " Eric Sunshine
2021-12-02 23:58   ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.