Skip to content

Commit 6a117da

Browse files
Denton-Lgitster
authored andcommitted
hooks--pre-push.sample: modernize script
The preferred form for a command substitution is $() over ``. Use this form for the command substitution in the sample hook. The preferred form for conditional tests is to use `test` over []. Replace [] with `test`. Finally, replace all instances of "sha" with "oid". Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit 6a117da

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

templates/hooks--pre-push.sample

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Information about the commits which are being pushed is supplied as lines to
1515
# the standard input in the form:
1616
#
17-
# <local ref> <local sha1> <remote ref> <remote sha1>
17+
# <local ref> <local oid> <remote ref> <remote oid>
1818
#
1919
# This sample shows how to prevent push of commits where the log message starts
2020
# with "WIP" (work in progress).
@@ -24,25 +24,25 @@ url="$2"
2424

2525
z40=0000000000000000000000000000000000000000
2626

27-
while read local_ref local_sha remote_ref remote_sha
27+
while read local_ref local_oid remote_ref remote_oid
2828
do
29-
if [ "$local_sha" = $z40 ]
29+
if test "$local_oid" = $z40
3030
then
3131
# Handle delete
3232
:
3333
else
34-
if [ "$remote_sha" = $z40 ]
34+
if test "$remote_oid" = $z40
3535
then
3636
# New branch, examine all commits
37-
range="$local_sha"
37+
range="$local_oid"
3838
else
3939
# Update to existing branch, examine new commits
40-
range="$remote_sha..$local_sha"
40+
range="$remote_oid..$local_oid"
4141
fi
4242

4343
# Check for WIP commit
44-
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
45-
if [ -n "$commit" ]
44+
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
45+
if test -n "$commit"
4646
then
4747
echo >&2 "Found WIP commit in $local_ref, not pushing"
4848
exit 1

0 commit comments

Comments
 (0)