Thread (3 messages) 3 messages, 3 authors, 2024-07-30

Re: Output of git checkout goes to stderr

From: Karthik Nayak <hidden>
Date: 2024-07-30 07:46:35

Sayooj Surendran [off-list ref] 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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help