X-Git-Url: https://git.madduck.net/code/fbi-announce.git/blobdiff_plain/901d9ab7629f0ac984349ec6ee70441feec7bbb6..c853b83790da6402b7a6f4b954b9503c23dfef7e:/post-receive-hook.sh?ds=inline diff --git a/post-receive-hook.sh b/post-receive-hook.sh index b9b7d29..c107292 100755 --- a/post-receive-hook.sh +++ b/post-receive-hook.sh @@ -6,17 +6,27 @@ # # Distributed under the terms of the Artistic Licence 2.0 # +# +# Link this to $GIT_DIR/hooks/post-receive (or …/update). +# set -eu -refname=$3 -rev=$(git rev-parse ${refname}) -oldhead=$1 -newhead=$2 - realself=$(readlink -f ${0}) siblingscript="${realself%/*}/fbi-announce.sh" -for commit in $(git rev-parse --not --branches | grep -v ${rev} | - git rev-list --reverse --stdin ${oldhead}..${newhead}); do - ${siblingscript} ${refname} ${commit} -done +process_update() +{ + for commit in $(git rev-parse --not --branches | + grep -v $(git rev-parse ${3}) | + git rev-list --reverse --stdin ${1}..${2}); do + ${siblingscript} ${3} ${commit} + done +} + +if [ $# -eq 3 ]; then + process_update "${@}" +else + while read oldrev newrev refname; do + process_update "${oldrev}" "${newrev}" "${refname}" + done +fi