#!/bin/sh echo " ----------------------------- " echo "| Inside pre-receive hook file |" echo " ----------------------------- " read oldRev newRev refName echo " Printing arguments passed to this file:" echo " Old Revision = $oldRev" echo " New Revision = $newRev" echo " Reference Name = $refName" cd D:/Code/Learning/GitSvnWorkflow/2-Git-Svn-Repo unset GIT_DIR case "$refName" in refs/heads/*) # This is a head push echo "Head Push" lastCommitSHA=$(git log -1 --pretty=format:%s | cut -d \: -f 1) echo " Last Commit SHA = $lastCommitSHA" exitCode=1 if [ "$oldRev" == "$lastCommitSHA" ]; then echo "Old Rev and Last Commit SHA1 hash match. Exiting with code 0" exitCode=0 else echo "Old Rev and Last Commit SHA1 hash DO NOT match. Exiting with code 1" fi ;; esac echo " ------------------------------------------ " echo "| pre-receive hook file execution complete |" echo " ------------------------------------------ " exit $exitCode