* Output of git checkout goes to stderr
@ 2024-07-30 5:44 Sayooj Surendran
2024-07-30 7:36 ` Eric Sunshine
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sayooj Surendran @ 2024-07-30 5:44 UTC (permalink / raw)
To: git
Hi,
Noticed that the output of git checkout command is going to stderr
channel. Is this an intended behaviour?
git version: 2.45.2
terminal output:
❯ git checkout -b test > stdout.txt 2> stderr.txt
❯ cat stdout.txt
❯ cat stderr.txt
Switched to a new branch 'test'
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Output of git checkout goes to stderr
2024-07-30 5:44 Output of git checkout goes to stderr Sayooj Surendran
@ 2024-07-30 7:36 ` Eric Sunshine
2024-07-30 7:46 ` Karthik Nayak
2024-07-30 15:45 ` Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Eric Sunshine @ 2024-07-30 7:36 UTC (permalink / raw)
To: Sayooj Surendran; +Cc: git
On Tue, Jul 30, 2024 at 1:44 AM Sayooj Surendran
<sayooj.surendran@bigbinary.com> wrote:
> Noticed that the output of git checkout command is going to stderr
> channel. Is this an intended behaviour?
Yes, it is intentional. Git's Documentation/CodingGuidelines has this to say:
--- >8 ---
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.
--- >8 ---
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Output of git checkout goes to stderr
2024-07-30 5:44 Output of git checkout goes to stderr Sayooj Surendran
2024-07-30 7:36 ` Eric Sunshine
@ 2024-07-30 7:46 ` Karthik Nayak
2024-07-30 15:45 ` Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Karthik Nayak @ 2024-07-30 7:46 UTC (permalink / raw)
To: Sayooj Surendran, git
[-- Attachment #1: Type: text/plain, Size: 1292 bytes --]
Sayooj Surendran <sayooj.surendran@bigbinary.com> writes:
Hello,
> Hi,
> Noticed that the output of git checkout command is going to stderr
> channel. Is this an intended behaviour?
> git version: 2.45.2
> terminal output:
>
> ❯ git checkout -b test > stdout.txt 2> stderr.txt
> ❯ cat stdout.txt
> ❯ cat stderr.txt
> Switched to a new branch 'test'
Thanks for reporting, this seems to be as expected. Note that all
chatty feedback is routed to stderr in Git.
This is also documented in 'Documentation/CodingGuidelines':
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.
Thanks,
Karthik
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Output of git checkout goes to stderr
2024-07-30 5:44 Output of git checkout goes to stderr Sayooj Surendran
2024-07-30 7:36 ` Eric Sunshine
2024-07-30 7:46 ` Karthik Nayak
@ 2024-07-30 15:45 ` Junio C Hamano
2 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2024-07-30 15:45 UTC (permalink / raw)
To: Sayooj Surendran; +Cc: git
Sayooj Surendran <sayooj.surendran@bigbinary.com> writes:
> Noticed that the output of git checkout command is going to stderr
> channel. Is this an intended behaviour?
Show messages meant for human consumptions (not just errors and
warnings, but informational messages and eye-candy progress bars) to
the standard error stream, and using the standard output stream to
show what informational commands are asked to produce (e.g. running
"git status" would describe the status of the current working tree
to the standard output stream), is very much in line with the
original design we laid out in 2005 when Git was still very young,
and continues to be "intended" behaviour to this day.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-30 15:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-30 5:44 Output of git checkout goes to stderr Sayooj Surendran
2024-07-30 7:36 ` Eric Sunshine
2024-07-30 7:46 ` Karthik Nayak
2024-07-30 15:45 ` Junio C Hamano
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).