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>
This commit is contained in:

committed by
Junio C Hamano

parent
6a117da6e5
commit
8c7e505950
@ -22,16 +22,16 @@
|
|||||||
remote="$1"
|
remote="$1"
|
||||||
url="$2"
|
url="$2"
|
||||||
|
|
||||||
z40=0000000000000000000000000000000000000000
|
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||||
|
|
||||||
while read local_ref local_oid remote_ref remote_oid
|
while read local_ref local_oid remote_ref remote_oid
|
||||||
do
|
do
|
||||||
if test "$local_oid" = $z40
|
if test "$local_oid" = "$zero"
|
||||||
then
|
then
|
||||||
# Handle delete
|
# Handle delete
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
if test "$remote_oid" = $z40
|
if test "$remote_oid" = "$zero"
|
||||||
then
|
then
|
||||||
# New branch, examine all commits
|
# New branch, examine all commits
|
||||||
range="$local_oid"
|
range="$local_oid"
|
||||||
|
Reference in New Issue
Block a user