From 0b51e9b6b328ed3e622728eae68b4988eefdbf5b Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 9 Jun 2011 18:02:28 +0300 Subject: [PATCH] git: post-receive-email hook again Check all revisions from new to old for merges, not just the topmost. --- git/post-receive-email | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/git/post-receive-email b/git/post-receive-email index beecf43..7e6d1f8 100755 --- a/git/post-receive-email +++ b/git/post-receive-email @@ -709,21 +709,37 @@ else # push. We want one per commit. As long as we're # in fast-forward-only world, this should do the # right thing. - if (expr "$oldrev" : '0*$' >/dev/null || # create - expr "$newrev" : '0*$' >/dev/null || # delete - (! expr "$refname" : "refs/heads/" > /dev/null) || # not a branch - git rev-parse --verify --quiet "$newrev"^2 > /dev/null) # merge commit + if (expr "$oldrev" : '0*$' >/dev/null || # create + expr "$newrev" : '0*$' >/dev/null || # delete + ! expr "$refname" : "refs/heads/" > /dev/null) # not a branch then # Just one email. generate_email $oldrev $newrev $refname | send_mail else - # Simple branch update, one mail per commit. - lastrev=$oldrev - for step in $(git rev-list --reverse $oldrev..$newrev) - do - generate_email $lastrev $step $refname | send_mail - lastrev=$step - done + # Get all revisions from old to new. + revlist=$(git rev-list --reverse $oldrev..$newrev) + no_merges=true + # Check for merges. + for rev in $revlist + do + if ($no_merges && ! git rev-parse --verify --quiet "$rev"^2 > /dev/null) + then + no_merges=false + fi + done + if $no_merges + then + # Simple branch update, one mail per commit. + lastrev=$oldrev + for step in $revlist + do + generate_email $lastrev $step $refname | send_mail + lastrev=$step + done + else + # There's a merge -- just one email. + generate_email $oldrev $newrev $refname | send_mail + fi fi done fi -- 1.7.10.4