]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hooks--update.sample: use hash-agnostic zero OID
authorDenton Liu <liu.denton@gmail.com>
Wed, 23 Sep 2020 09:38:45 +0000 (02:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Sep 2020 16:31:45 +0000 (09:31 -0700)
The update 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>
templates/hooks--update.sample

index 5014c4b31cb9700dbd458c8841d8cd91d3b8773c..c4d426bc6ee9430ee7813263ce6d5da7ec78c3c6 100755 (executable)
@@ -60,7 +60,7 @@ esac
 
 # --- Check types
 # if $newrev is 0000...0000, it's a commit to delete a ref.
-zero="0000000000000000000000000000000000000000"
+zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
 if [ "$newrev" = "$zero" ]; then
        newrev_type=delete
 else