git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bug report: pre-commit & pre-push hook output is redirected differently
@ 2022-07-06 20:40 Adam Zethraeus
  2022-07-06 21:06 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Adam Zethraeus @ 2022-07-06 20:40 UTC (permalink / raw)
  To: git

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.

```
> 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

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

end of thread, other threads:[~2022-07-07 20:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 20:40 bug report: pre-commit & pre-push hook output is redirected differently Adam Zethraeus
2022-07-06 21:06 ` Junio C Hamano
2022-07-07 12:40   ` Ævar Arnfjörð Bjarmason
2022-07-07 16:57     ` Junio C Hamano
2022-07-07 20:55       ` Emily Shaffer

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).