meta:hooks:pre-push: Adjust to more concise style

Adjust the sample code from git to a more concise coding style, placing
{do,then} on the same line and using `[` instead of `test`.
This commit is contained in:
2022-07-12 20:40:56 +02:00
parent ee6153734a
commit 45cb607385

View File

@@ -26,15 +26,12 @@ url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
while read local_ref local_oid remote_ref remote_oid; do
if [ "$local_oid" = "$zero" ]; then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
if [ "$remote_oid" = "$zero" ]; then
# New branch, examine all commits
range="$local_oid"
else
@@ -46,8 +43,7 @@ do
pattern='^(WIP|(fixup|squash)!)'
commits="$(git rev-list -E --oneline --grep "$pattern" "$range")"
if test -n "$commits"
then
if [ -n "$commits" ]; then
printf >&2 "$local_ref: Commits in progress:\n%s" "$commits"
printf >&2 "Aborting push"
exit 1