@matheusbsbs / matheus-bagliano / commits / 8c7e505950
Fork 0

hooks--pre-push.sample: use hash-agnostic zero OID

The pre-push sample hook has the zero OID hardcoded as 40 zeros. However, with the introduction of SHA-256 support, this assumption no longer holds true. Replace the hardcoded $z40 with a call to git hash-object --stdin </dev/null | tr '[0-9a-f]' '0' so the sample hook becomes hash-agnostic. 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 8c7e5059506c6840bfbd4dd8d1730784a5689719
1 file changed +3 -3
templates/hooks--pre-push.sample
+3 -3
@@ -22,16 +22,16 @@
22 remote="$1"
23 url="$2"
24
25 -z40=0000000000000000000000000000000000000000
25 +zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
26
27 while read local_ref local_oid remote_ref remote_oid
28 do
29 - if test "$local_oid" = $z40
29 + if test "$local_oid" = "$zero"
30 then
31 # Handle delete
32 :
33 else
34 - if test "$remote_oid" = $z40
34 + if test "$remote_oid" = "$zero"
35 then
36 # New branch, examine all commits
37 range="$local_oid"