iDev
iDev

Reputation: 2421

git update hook not receiving any arguments

I read up online that git hook accepts 3 arguments:

  1. the name of the ref being updated,

  2. the old object name stored in the ref,

  3. and the new object name to be stored in the ref.

I am trying to access these arguments but it's empty. What could be wrong here?

#!/bin/bash


echo $@
refname="$1"
oldrev="$2"
newrev="$3"

Based on the comments, I tried adding an echo statement echo "In update hook: Args:$@" and heres the output that I see:

$git push
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 563 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 1 (delta 0)
remote: In update hook: Args:
remote:
remote:

Upvotes: 0

Views: 319

Answers (1)

iDev
iDev

Reputation: 2421

Thank you Bjoern for the reference link. Based on the link you provided, I am able to retreive the arguments:

Source: git: empty arguments in post-receive hook posted by estani

read oldrev newrev refname
echo "Old revision: $oldrev"
echo "New revision: $newrev"
echo "Reference name: $refname"

Upvotes: 1

Related Questions