git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git branch outputs usage message on stderr
@ 2025-01-15 11:21 Jonas Konrad
  2025-01-15 11:36 ` Matěj Cepl
  0 siblings, 1 reply; 27+ messages in thread
From: Jonas Konrad @ 2025-01-15 11:21 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]

Hey, please find the report below.

What did you do before the bug happened? (Steps to reproduce your issue)
I opened a terminal on Arch Linux with a bash shell and called `git 
branch -h` to get a usage overview of git's `branch` command. I then 
tried processing the output with `grep` by `git branch -h | grep list` 
which gave the whole (unfiltered) output, i.e., the displayed message 
was not processed by `grep`.

What did you expect to happen? (Expected behavior)
Pipe redirects stdout to grep (here: usage info of git branch) and grep 
can filter it.

What happened instead? (Actual behavior)
`git branch -h` output was not redirected to `grep`. Instead, it went to 
stderr, bypassing the pipe. Using `|&` as pipe gives the expected result 
and confirms that the usage output is indeed redirected to stderr.

What's different between what you expected and what actually happened?
To me, `git branch -h` (invoked without any non-valid option) shall 
output its help/usage message to stdout, and exit without error status 
(exit status 0).

Anything else you want to add:
In fact, `git branch -h` exits with a non-zero status. This is coherent 
with outputting the usage message on stderr and made me think the 
behavior could be intended. I can hardly imagine, as outputting usage 
info to stderr to me only made sense if `git branch` is invoked with, 
e.g., a non-valid option (if at all). I would prefer the usage output on 
stderr even in this case, but allow for a non-zero exit status of git 
branch. Also, `git -h` gives its output on stdout.


[System Info]
git version:
git version 2.48.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.11.1
OpenSSL: OpenSSL 3.4.0 22 Oct 2024
zlib: 1.3.1
uname: Linux 6.12.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Jan 2025 
22:52:26 +0000 x86_64
compiler info: gnuc: 14.2
libc info: glibc: 2.40
$SHELL (typically, interactive shell): /bin/bash

Best,

-- 
Jonas Konrad, PhD Student
Institute for Geoinformatics, University Münster
Heisenbergstr. 2, 48149 Münster


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6990 bytes --]

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

end of thread, other threads:[~2025-01-16 10:24 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15 11:21 Git branch outputs usage message on stderr Jonas Konrad
2025-01-15 11:36 ` Matěj Cepl
2025-01-15 14:47   ` Jonas Konrad
2025-01-15 15:28   ` Junio C Hamano
2025-01-15 16:55     ` Kristoffer Haugsbakk
2025-01-15 17:14       ` Jeff King
2025-01-15 17:49         ` Junio C Hamano
2025-01-15 17:56         ` Junio C Hamano
2025-01-15 18:24           ` Jeff King
2025-01-15 21:16             ` Junio C Hamano
2025-01-15 21:29               ` Jeff King
2025-01-15 21:56                 ` Junio C Hamano
2025-01-15 22:27                   ` Jeff King
2025-01-15 23:32                     ` Junio C Hamano
2025-01-16  1:21                       ` Junio C Hamano
2025-01-16 10:24                       ` Jeff King
2025-01-15 22:11                 ` Junio C Hamano
2025-01-15 22:28                   ` Jeff King
2025-01-15 23:35                     ` Junio C Hamano
2025-01-15 18:29           ` Junio C Hamano
2025-01-15 18:33             ` Kristoffer Haugsbakk
2025-01-15 21:13               ` Junio C Hamano
2025-01-15 17:14       ` Jonas Konrad
2025-01-15 17:53         ` Kristoffer Haugsbakk
2025-01-15 17:19       ` Junio C Hamano
2025-01-15 17:39         ` Kristoffer Haugsbakk
2025-01-15 17:47           ` 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).