Re: git pre-push hook not getting the lines from STDIN
- From
Wesley <wesleys@opperschaap.net>
- Date
- Aug 9, 2023, 12:38 UTC
- Message-ID
- <1eef1bff-8b65-abac-e75b-acd98b013e7b@opperschaap.net>
- In-Reply-To
- <m0wmy4lbd0.fsf@epic96565.epic.com>
Hello Sean,
Show 8 quoted lines
> Have you looked at simplifying this script to the bare minimum to > identify the issue? I might suggest starting by just slurping stdin and > writing that to a file: > > #!/bin/sh > echo "$@" >pre-push.$$.args > cat >>pre-push.$$.stdin > exit 1
>
> I'm not familiar with the particulars of Zsh scripting, but I suspect > there is a bug in your script. Zsh works with my script, too, so it > doesn't appear to be a problem with Zsh itself.
This is the bare miminum. You can also take the example script from the git sources which does it in bash[^1] and uses while read syntax. It produces the same output, with the exception that you don't see the empty echo statements because it cannot read the input from STDIN and exits immediately.
It seems it works intermittently.
In my zsh repo for example with the following remotes:
origin git@gitlab.com:waterkip/zsh (fetch) origin git@gitlab.com:waterkip/zsh (push) upstream git://git.code.sf.net/p/zsh/code (fetch) upstream git://git.code.sf.net/p/zsh/code (push)
Locally my patchlevel-in_version branch is at commit b7f280ab5. If I `git pull --rebase upstream master` and than push it (`git push origin HEAD) with hook configured it doesn't show any of the things I expect in LOCAL_REF etc. This happens with my version of the script and the version provided by git (in .git/hooks/pre-push.sample).
Cheers, Wesley
[^1]: https://github.com/git/git/blob/87c86dd14abe8db7d00b0df5661ef8cf147a72a3/templates/hooks--pre-push.sample
-- Wesley Why not both?