diff --git a/tools/git-notify b/tools/git-notify
index faa1785053bf735a90cf713da3b1992b5ca393ab..851429658fd238d820a06e6d6e2db62bea3431b3 100755 (executable)
--- a/tools/git-notify
+++ b/tools/git-notify
# -A Omit the author name from the mail subject
# -C Show committer in the body if different from the author
# -c name Send CIA notifications under specified project name
-# -H The mail(1) utility doesn't accept headers via "-a"
# -m addr Send mail notifications to specified address
# -n max Set max number of individual mails to send
# -r name Set the git repository name
# some parameters you may want to change
-# set this to something that takes "-s"
-my $mailer = "/usr/bin/mail";
+# sendmail's pathname
+my $sendmail = "/usr/sbin/sendmail";
# CIA notification address
-my $cia_address = "cia\@cia.navi.cx";
+my $cia_address = "cia\@cia.vc";
# debug mode
my $debug = 0;
# configuration parameters
-# the $mailer doesn't accept headers via "-a" (can be set with the -H option)
-my $legacy_mail = git_config( "notify.legacymail" );
-
# omit the author from the mail subject (can be set with the -A option)
my $omit_author = git_config( "notify.omitauthor" );
# abbreviate the SHA1 name within gitweb URLs (can be set with the -z option)
my $abbreviate_url = git_config( "notify.shorturls" );
+# don't report merge commits (can be set with the -X option)
+my $ignore_merges = git_config( "notify.ignoremerges" );
+
# enable compatibility with SourceForge's gitweb (can be set with the -S option)
my $sourceforge = git_config( "notify.sourceforge" );
# umask for creating the state file (can be set with -U option)
my $mode_mask = git_config( "notify.umask" ) || 002;
-# Extra options to git rev-list
-my @revlist_options;
-
sub usage()
{
print "Usage: $0 [options] [--] old-sha1 new-sha1 refname\n";
print " -A Omit the author name from the mail subject\n";
print " -C Show committer in the body if different from the author\n";
print " -c name Send CIA notifications under specified project name\n";
- print " -H The mail(1) utility doesn't accept headers via `-a'\n";
print " -m addr Send mail notifications to specified address\n";
print " -n max Set max number of individual mails to send\n";
print " -r name Set the git repository name\n";
die "Cannot open pipe: $!" if not defined $pid;
if (!$pid)
{
- exec "git", "rev-list", @revlist_options, @args or die "Cannot execute rev-list: $!";
+ exec "git", "rev-list", "--reverse", @args or die "Cannot execute rev-list: $!";
}
while (<REVLIST>)
{
@args = ( "^$old_sha1" ) unless $old_sha1 eq '0' x 40;
push @args, $new_sha1, @exclude_list;
+ unshift @args, "--no-merges" if $ignore_merges;
my $revlist = git_rev_list(@args);
elsif ($arg eq '-A') { $omit_author = 1; }
elsif ($arg eq '-C') { $show_committer = 1; }
elsif ($arg eq '-c') { $cia_project_name = shift @ARGV; }
- elsif ($arg eq '-H') { $legacy_mail = 1; }
elsif ($arg eq '-m') { $commitlist_address = shift @ARGV; }
elsif ($arg eq '-n') { $max_individual_notices = shift @ARGV; }
elsif ($arg eq '-r') { $repos_name = shift @ARGV; }
elsif ($arg eq '-U') { $mode_mask = shift @ARGV; }
elsif ($arg eq '-u') { $gitweb_url = shift @ARGV; }
elsif ($arg eq '-i') { push @include_list, shift @ARGV; }
+ elsif ($arg eq '-X') { $ignore_merges = 1; }
elsif ($arg eq '-x') { push @exclude_list, shift @ARGV; }
- elsif ($arg eq '-X') { push @revlist_options, "--no-merges"; }
elsif ($arg eq '-z') { $abbreviate_url = 1; }
elsif ($arg eq '-d') { $debug++; }
else { usage(); }
{
my ($name, $subject, $content_type, @text) = @_;
- $subject = "[$repos_name] $subject" if $emit_repo;
+ $subject = "[$repos_name] $subject" if ($emit_repo and $name ne $cia_address);
$subject = encode("MIME-Q",$subject);
+ my @header = ("To: $name", "Subject: $subject", "Content-Type: $content_type");
+
if ($debug)
{
binmode STDOUT, ":utf8";
print "---------------------\n";
- print "To: $name\n";
- print "Subject: $subject\n";
- print "Content-Type: $content_type\n";
- print "\n", join("\n", @text), "\n";
+ print join("\n", @header), "\n\n", join("\n", @text), "\n";
}
else
{
return unless defined $pid;
if (!$pid)
{
- my @mailer_options = ( "-s", $subject );
-
- unless ($legacy_mail)
- {
- push @mailer_options, "-a", "Content-Type: $content_type";
- }
- exec $mailer, @mailer_options, $name or die "Cannot exec $mailer";
+ exec $sendmail, "-t", "-oi", "-oem" or die "Cannot exec $sendmail";
}
binmode MAIL, ":utf8";
- print MAIL join("\n", @text), "\n";
- close MAIL or warn $! ? "Cannot execute $mailer: $!" : "$mailer exited with status: $?";
+ print MAIL join("\n", @header), "\n\n", join("\n", @text), "\n";
+ close MAIL or warn $! ? "Cannot execute $sendmail: $!" : "$sendmail exited with status: $?";
}
}