diff mbox series

[4/4] hooks--update.sample: use hash-agnostic null OID

Message ID 42d282988961545fb1ab6405a08368d14ffa1450.1600427894.git.liu.denton@gmail.com (mailing list archive)
State Superseded
Headers show
Series sample hooks: become hash agnostic | expand

Commit Message

Denton Liu Sept. 18, 2020, 11:19 a.m. UTC
The update 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 <liu.denton@gmail.com>
---
 templates/hooks--update.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Sunshine Sept. 18, 2020, 5:08 p.m. UTC | #1
On Fri, Sep 18, 2020 at 7:19 AM Denton Liu <liu.denton@gmail.com> wrote:
> The update 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 <liu.denton@gmail.com>
> ---
> diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
> @@ -60,7 +60,7 @@ esac
> -zero="0000000000000000000000000000000000000000"
> +zero="$(git rev-list --null-oid)"

Definitely want a s/rev-list/rev-parse/ here.
diff mbox series

Patch

diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
index 5014c4b31c..5316362af5 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 rev-list --null-oid)"
 if [ "$newrev" = "$zero" ]; then
 	newrev_type=delete
 else