Skip to content

Commit 8c7e505

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a117da commit 8c7e505

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

templates/hooks--pre-push.sample

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
remote="$1"
2323
url="$2"
2424

25-
z40=0000000000000000000000000000000000000000
25+
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
2626

2727
while read local_ref local_oid remote_ref remote_oid
2828
do
29-
if test "$local_oid" = $z40
29+
if test "$local_oid" = "$zero"
3030
then
3131
# Handle delete
3232
:
3333
else
34-
if test "$remote_oid" = $z40
34+
if test "$remote_oid" = "$zero"
3535
then
3636
# New branch, examine all commits
3737
range="$local_oid"

0 commit comments

Comments
 (0)