#!/bin/sh awk -v origin_name="$1" ' @include ".git/hooks/commit-msg-files.awk" # If the local SHA is all zeroes, ignore it. $2 ~ /^0{40}$/ { next } $2 ~ /^[a-z0-9]{40}$/ { newref = $2 # If the remote SHA is all zeroes, go backwards until we find a SHA on # an origin branch. if ($4 ~ /^0{40}$/) { back = 0 while ((("git branch -r -l '\''" origin_name "/*'\'' --contains " \ newref "~" back) | getline) == 0) { back++ } ("git rev-parse " newref "~" back) | getline oldref if (!(oldref ~ /^[a-z0-9]{40}$/)) { # The SHA is misformatted?! exit 2 } } else if ($4 ~ /^[a-z0-9]{40}$/) { oldref = $4 } else { # The remote SHA is misformatted?! exit 2 } # Iterate over every SHA after oldref, up to (and including) newref. while ((("git rev-list --reverse " oldref ".." newref) | getline) > 0) { if (! check_commit_msg_files($0)) { status = 1 } } } END { if (status != 0) { print "Push aborted; please see the file '\''CONTRIBUTE'\''" } exit status } '