Index: git/README.txt =================================================================== --- git/README.txt (revision 16616) +++ git/README.txt (working copy) @@ -49,7 +49,7 @@ * mmencode (converters/mmencode, for email hooks) * gnupg (for verify `push --signed`) * python3 (some hooks need it) -* pcre (some hooks need pcregrep) +* pcre2 (some hooks need pcre2grep) ### Configuration Index: git/gitrepo/gitolite/local/VREF/APPROVERS-CHECK =================================================================== --- git/gitrepo/gitolite/local/VREF/APPROVERS-CHECK (revision 16616) +++ git/gitrepo/gitolite/local/VREF/APPROVERS-CHECK (working copy) @@ -48,6 +48,10 @@ } my ($ref, $old, $new) = @ARGV; + +# Ref deletion: nothing new to check. +exit 0 if $new =~ /^0+$/; + my $repo = $ARGV[7]; my $approvers_conf = "$conf_base/$repo/approvers"; Index: git/gitrepo/gitolite/local/VREF/COMMITTER-CHECK =================================================================== --- git/gitrepo/gitolite/local/VREF/COMMITTER-CHECK (revision 16616) +++ git/gitrepo/gitolite/local/VREF/COMMITTER-CHECK (working copy) @@ -19,6 +19,9 @@ my ($ref, $old, $new) = @ARGV; +# Ref deletion: nothing new to check. +exit 0 if $new =~ /^0+$/; + #if ($ref =~ "^refs/heads/vendor/") { if ($ref =~ "^refs/heads/vendor/openzfs/") { # vendor branch is an exception Index: git/gitrepo/gitolite/local/hooks/repo-specific/author-checker =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/author-checker (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/author-checker (working copy) @@ -24,6 +24,8 @@ foreach my $line () { my ($old, $new, $ref) = split / /, $line; + # Ref deletion: nothing new to check. + next if $new =~ /^0+$/; for my $rev (`git log --format="%an\t%ae\t%cn\t%ce\t%H\t%s" $new --not --all`) { chomp($rev); my ($author_name, $author_email, $committer_name, $committer_email, $hash, $subject) = split /\t/, $rev; Index: git/gitrepo/gitolite/local/hooks/repo-specific/doc-hook =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/doc-hook (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/doc-hook (working copy) @@ -348,6 +348,9 @@ chomp; my ($old, $new, $ref) = split / /; + # Ref deletion: nothing new to check. + next if $new =~ /^0+$/; + for my $rev ($git->command('log', '--format=%H', $new, '--not', '--all')) { # Get the raw body of the commit Index: git/gitrepo/gitolite/local/hooks/repo-specific/notify-bugzilla =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/notify-bugzilla (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/notify-bugzilla (working copy) @@ -76,7 +76,13 @@ ;; esac - generate_${change_type}_${fn_name}_email + gen_fn=generate_${change_type}_${fn_name}_email + + # Not every change has an email (e.g. ref deletions); skip those. + if ! type "${gen_fn}" >/dev/null 2>&1; then + return 0 + fi + ${gen_fn} } generate_create_branch_email() Index: git/gitrepo/gitolite/local/hooks/repo-specific/notify-mailinglist =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/notify-mailinglist (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/notify-mailinglist (working copy) @@ -67,7 +67,7 @@ ( echo "To: ${recipients}" - if [ ${pusher_email_l} != ${author_email_l} ]; then + if [ -n "${author_email_l}" ] && [ "${pusher_email_l}" != "${author_email_l}" ]; then echo "Cc: ${author_name} <${author_email}>" fi echo "From: ${from_pusher}" @@ -104,11 +104,13 @@ pusher_email_l=$(echo ${pusher_email} | tr 'A-Z' 'a-z') from_pusher="${pusher_name} <${pusher_email}>" - author_name=$(git show --no-patch --format="%an" ${rev} 2>/dev/null) + # "git show --format" on a tag object also prints the tag header and + # message, so take the tagger from the tag itself. + author_name=$(git for-each-ref --format='%(taggername)' "${refname}" 2>/dev/null) if [ -n "$(echo "${author_name}" | pcre2grep -n "[\x80-\xFF]")" ]; then author_name=$(q_encode "${author_name}") fi - author_email=$(git show --no-patch --format="%ae" ${rev} 2>/dev/null) + author_email=$(git for-each-ref --format='%(taggeremail)' "${refname}" 2>/dev/null | tr -d '<>') author_email_l=$(echo ${author_email} | tr 'A-Z' 'a-z') subject="Create tag ${short_refname}" @@ -116,7 +118,7 @@ ( echo "To: ${recipients}" - if [ ${pusher_email_l} != ${author_email_l} ]; then + if [ -n "${author_email_l}" ] && [ "${pusher_email_l}" != "${author_email_l}" ]; then echo "Cc: ${author_name} <${author_email}>" fi echo "From: ${from_pusher}" @@ -155,10 +157,16 @@ esac if [ -n "${vendor_branch}" ] && [ "${refname_type}" = "branch" ]; then - generate_vendor_${change_type}_${fn_name}_email + gen_fn=generate_vendor_${change_type}_${fn_name}_email else - generate_${change_type}_${fn_name}_email + gen_fn=generate_${change_type}_${fn_name}_email fi + + # Not every change has an email (e.g. ref deletions); skip those. + if ! type "${gen_fn}" >/dev/null 2>&1; then + return 0 + fi + ${gen_fn} } generate_create_branch_email() @@ -176,6 +184,51 @@ process_tag ${newrev} } +generate_delete_atag_email() +{ + process_ref_delete +} + +# Lightweight tags end up as fn_name "general". +generate_delete_general_email() +{ + process_ref_delete +} + +process_ref_delete() +{ + pusher_name=$(getent passwd ${GL_USER} | cut -d: -f 5 | cut -d, -f 1) + if [ -n "$(echo "${pusher_name}" | pcre2grep -n "[\x80-\xFF]")" ]; then + pusher_name=$(q_encode "${pusher_name}") + fi + from_pusher="${pusher_name} <${GL_USER}@FreeBSD.org>" + + oldrev_short=$(git rev-parse --short $oldrev 2>/dev/null) + + ( + echo "To: ${recipients}" + echo "From: ${from_pusher}" + echo "Subject: ${emailprefix}${oldrev_short} - Delete ${refname_type} ${short_refname}" + echo "MIME-Version: 1.0" + echo "Content-Type: text/plain; charset=utf-8" + echo "Content-Transfer-Encoding: 8bit" + echo "X-Git-Committer: ${GL_USER}" + echo "X-Git-Repository: ${GL_REPO}" + echo "X-Git-Refname: $refname" + echo "X-Git-Reftype: $refname_type" + echo "X-Git-Oldrev: $oldrev" + echo "X-Git-Newrev: $newrev" + echo "Auto-Submitted: auto-generated" + echo "" + echo "The $refname_type $short_refname has been deleted by ${GL_USER}." + echo "" + echo "It previously pointed to ${oldrev}:" + echo "" + # The object is unreferenced now but still present until gc. + git show --format=fuller --date=iso-local --no-patch $oldrev 2>/dev/null + ) | limit_lines ${maxlines} | send_mail +} + generate_vendor_create_branch_email() { process_vendor_revisions Index: git/gitrepo/gitolite/local/hooks/repo-specific/ports-hook =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/ports-hook (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/ports-hook (working copy) @@ -571,6 +571,9 @@ unsupported_quarterly($ref); + # Ref deletion: nothing new to check. + next if $new =~ /^0+$/; + for my $rev ($git->command('log', '--format=%H', $new, '--not', '--all')) { # Get the raw body of the commit Index: git/gitrepo/gitolite/local/hooks/repo-specific/src-hook =================================================================== --- git/gitrepo/gitolite/local/hooks/repo-specific/src-hook (revision 16616) +++ git/gitrepo/gitolite/local/hooks/repo-specific/src-hook (working copy) @@ -300,6 +300,9 @@ chomp; my ($old, $new, $ref) = split / /; + # Ref deletion: nothing new to check. + next if $new =~ /^0+$/; + for my $rev ($git->command('log', '--format=%H', $new, '--not', '--all')) { # Get the raw body of the commit