Re: git fails with a broken pipe when one quits the pager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2021-01-31 02:47:59 +0100, Ævar Arnfjörð Bjarmason wrote:
> On Fri, Jan 15 2021, Vincent Lefevre wrote:
> > I had reported the following bug at
> >   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914896
> >
> > It still occurs with Git 2.30.0.
> >
> > Some git commands with a lot of output fail with a broken pipe when
> > one quits the pager (without going to the end of the output).
> >
> > For instance, in zsh:
> >
> > cventin% setopt PRINT_EXIT_VALUE
> > cventin% git log
> > zsh: broken pipe  git log
> > cventin% echo $?
> > 141
> > cventin% 
> >
> > This is annoying[...]
> 
> Yes it's annoying, but the annoying output is from zsh, not
> git. Consider a smarter implementation like:
> 
>     case $__exit_status in
>         0) __exit_emoji=😀;;
>         1) __exit_emoji=☹️ ;;
>         141) __exit_emoji=🤕 ;;
>         [...]
> 
> Then put the $__exit_emoji in your $PS1 prompt, now when you 'q' in a
> pager you know the difference between having quit at the full output
> being emitted or not.

FYI, I already have the exit status already in my prompt (the above
commands were just for the example). Still, the git behavior is
disturbing.

Moreover, this doesn't solve the issue when doing something like

  git log && some_other_command

> > And of course, I don't want to hide error messages by default, because
> > this would hide *real* errors.
> 
> Isn't the solution to this that your shell stops reporting failures due
> to SIGPIPE in such a prominent way then?

No! I want to be warned about real SIGPIPEs.

> > The broken pipe is internally expected, thus should not be reported
> > by git.
> >
> > Just to be clear: this broken pipe should be discarded only when git
> > uses its builtin pager feature, not with a general pipe, where the
> > error may be important.
> >
> > For instance,
> >
> > $ { git log ; echo "Exit status: $?" >&2 ; } | true
> >
> > should still output
> >
> > Exit status: 141
> 
> I don't get it, how is it less meaningful when git itself invokes the
> pager?

I don't understand your question. If I invoke the pager myself,
I don't get a SIGPIPE:

cventin:~/software/gcc-trunk> git log
cventin:~/software/gcc-trunk[PIPE]> git log|m
cventin:~/software/gcc-trunk>

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux