hooks:pre-push: Switch back to /bin/sh

It's not worth it to sacrifice the portability of the script for a bit
of integer-aid.
This commit is contained in:
2025-05-30 01:23:31 +02:00
parent d4d21ceb1d
commit 136b56688a

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# A hook script to verify what is about to be pushed. Called by "git push"
# after it has checked the remote status, but before anything has been pushed.
@@ -27,9 +27,10 @@ url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
# look for WIP at beginning or end of branch name
is_wip_branch=1
git rev-parse --symbolic-full-name --abbrev-ref HEAD \
| grep -Eqi '^wip($|[^[:alpha:]])|(^|[^[:alpha:]])wip$'
is_wip_branch=$((! $?))
| grep -Eqi '^wip($|[^[:alpha:]])|(^|[^[:alpha:]])wip$' \
|| is_wip_branch=0
while read local_ref local_oid remote_ref remote_oid; do
[ "$local_oid" != "$zero" ] || continue
@@ -46,7 +47,7 @@ while read local_ref local_oid remote_ref remote_oid; do
pattern='^(WIP|(fixup|squash)!)'
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
if [ -n "$commits" ] && ((!is_wip_branch)); then
if [ -n "$commits" ] && [ "$is_wip_branch" -eq 0 ]; then
printf >&2 "%s: Commits in progress:\n" "$local_ref"
printf >&2 "%s\n" "$commits"
printf >&2 "Aborting push\n"