diff mbox series

[v2,3/3] hooks--update.sample: use hash-agnostic zero OID

Message ID 784135549f2fd23a5135cb2b6c2c5ba525885814.1600853895.git.liu.denton@gmail.com (mailing list archive)
State Accepted
Commit d8d3d632f4165955da49032d50279c20cfbde2e5
Headers show
Series sample hooks: become hash agnostic | expand

Commit Message

Denton Liu Sept. 23, 2020, 9:38 a.m. UTC
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>
---
 templates/hooks--update.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
index 5014c4b31c..c4d426bc6e 100755
--- a/templates/hooks--update.sample
+++ b/templates/hooks--update.sample
@@ -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