summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-09-23 09:38:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-09-23 16:31:45 (GMT)
commit8c7e5059506c6840bfbd4dd8d1730784a5689719 (patch)
treee5487a64aff9bd6061860d3e5558fc3acde0834d /templates
parent6a117da6e523a82115733682f4d3f59755897d5a (diff)
downloadgit-8c7e5059506c6840bfbd4dd8d1730784a5689719.zip
git-8c7e5059506c6840bfbd4dd8d1730784a5689719.tar.gz
git-8c7e5059506c6840bfbd4dd8d1730784a5689719.tar.bz2
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>
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/hooks--pre-push.sample6
1 files changed, 3 insertions, 3 deletions
diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample
index d0f3019..4ce688d 100755
--- a/templates/hooks--pre-push.sample
+++ b/templates/hooks--pre-push.sample
@@ -22,16 +22,16 @@
remote="$1"
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
do
- if test "$local_oid" = $z40
+ if test "$local_oid" = "$zero"
then
# Handle delete
:
else
- if test "$remote_oid" = $z40
+ if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"