git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bug report: pre-commit & pre-push hook output is redirected differently

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 6, 2022, 21:06 UTC
Message-ID
<xmqqa69mgdde.fsf@gitster.g>
In-Reply-To
<CAP4e5TNdvE1gmt9bERT5sL+D3r4Fbypk57KJJ+wYHD=M=T+uWA@mail.gmail.com>
Adam Zethraeus <adam.zethraeus@includedhealth.com> writes:
Show 20 quoted lines
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> Installed identical pre-commit and pre-push hooks:
>
> ```
> #!/bin/bash
>
>>&1 echo "stdout"
>>&2 echo "stderr"
> exit 1
> ```
>
> What did you expect to happen? (Expected behavior)
>
> `git push` and `git commit` should have the same hook behavior.
>
> What happened instead? (Actual behavior)
>
> The pre-commit hook was run with stdout redirected to stderr but the
> pre-push hook's output was unaltered.

Without looking into it very much, the output of hooks is an area with known regression at 2.36, so let me redirect it to those who are likely to know it ;-)

Thanks for a report.
Show 48 quoted lines
>
> ```
>> git commit -m "-" 1>/dev/null
> stdout
> stderr
>> git commit -m "-" 2>/dev/null
>> git commit -m "-" --no-verify
>> git push 1>/dev/null
> stderr
> error: failed to push some refs to 'github.com:org/repo.git'
>> git push 2>/dev/null
> stdout
> ```
>
> What's different between what you expected and what actually happened?
>
> There was inconsistency in the behavior when I expected consistency.
>
> Anything else you want to add:
>
> ```
>> /bin/bash --version
> GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
> ```
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
>
>
> [System Info]
> git version:
> git version 2.37.0
> cpu: x86_64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> feature: fsmonitor--daemon
> uname: Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22
> PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64
> compiler info: clang: 13.1.6 (clang-1316.0.21.2.5)
> libc info: no libc information available
> $SHELL (typically, interactive shell): /bin/zsh
>
>
> [Enabled Hooks]
> pre-commit
> pre-push
Previous: Adam ZethraeusNext: Ævar Arnfjörð Bjarmason
Message 2 of 5 in “bug report: pre-commit & pre-push hook output is redirected differently”
  1. Adam ZethraeusJul 6, 2022
  2. Junio C HamanoJul 6, 2022
  3. Ævar Arnfjörð BjarmasonJul 7, 2022
  4. Junio C HamanoJul 7, 2022
  5. Emily ShafferJul 7, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.