Thread (19 messages) 19 messages, 5 authors, 2020-09-23
STALE2086d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 3/4] hooks--pre-push.sample: use hash-agnostic null OID

From: Denton Liu <hidden>
Date: 2020-09-18 11:19:38
Subsystem: the rest · Maintainer: Linus Torvalds

The pre-push sample hook has the null 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 rev-parse --null-oid` so the sample hook becomes hash-agnostic.

Signed-off-by: Denton Liu <redacted>
---
 templates/hooks--pre-push.sample | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index 64b5707553..b3bc5276bf 100755
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -22,16 +22,16 @@
 remote="$1"
 url="$2"
 
-z40=0000000000000000000000000000000000000000
+null_oid="$(git rev-parse --null-oid)"
 
 while read local_ref local_sha remote_ref remote_sha
 do
-	if [ "$local_sha" = $z40 ]
+	if [ "$local_sha" = "$null_oid" ]
 	then
 		# Handle delete
 		:
 	else
-		if [ "$remote_sha" = $z40 ]
+		if [ "$remote_sha" = "$null_oid" ]
 		then
 			# New branch, examine all commits
 			range="$local_sha"
-- 
2.28.0.618.gf4bc123cb7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help