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 <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Sep 23, 2020 at 02:38 UTC
6a117da6e523a82115733682f4d3f59755897d5a
1 file changed
+8
-8
templates/hooks--pre-push.sample
+8
-8
@@ -14,7 +14,7 @@
14
# Information about the commits which are being pushed is supplied as lines to
15
# the standard input in the form:
16
#
17
-# <local ref> <local sha1> <remote ref> <remote sha1>
17
+# <local ref> <local oid> <remote ref> <remote oid>
18
#
19
# This sample shows how to prevent push of commits where the log message starts
20
# with "WIP" (work in progress).
@@ -24,25 +24,25 @@ url="$2"
24
25
z40=0000000000000000000000000000000000000000
26
27
-while read local_ref local_sha remote_ref remote_sha
27
+while read local_ref local_oid remote_ref remote_oid
28
do
29
- if [ "$local_sha" = $z40 ]
29
+ if test "$local_oid" = $z40
30
then
31
# Handle delete
32
:
33
else
34
- if [ "$remote_sha" = $z40 ]
34
+ if test "$remote_oid" = $z40
35
then
36
# New branch, examine all commits
37
- range="$local_sha"
37
+ range="$local_oid"
38
else
39
# Update to existing branch, examine new commits
40
- range="$remote_sha..$local_sha"
40
+ range="$remote_oid..$local_oid"
41
fi
42
43
# 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"
46
then
47
echo >&2 "Found WIP commit in $local_ref, not pushing"
48
exit 1