From: Junio C Hamano Date: Sun, 9 May 2010 05:37:34 +0000 (-0700) Subject: Merge branch 'bg/send-email-smtpdomain' X-Git-Tag: v1.7.2-rc0~146 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/daa81c4a4a48a76e542293c025972e6a870fec9b?ds=inline;hp=-c Merge branch 'bg/send-email-smtpdomain' * bg/send-email-smtpdomain: send-email: Cleanup smtp-domain and add config Document send-email --smtp-domain send-email: Don't use FQDNs without a '.' send-email: Cleanup { style --- daa81c4a4a48a76e542293c025972e6a870fec9b diff --combined Documentation/config.txt index ced5db6e0f,0338d03d7e..e5aa2cacfa --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -198,11 -198,11 +198,11 @@@ core.quotepath: core.autocrlf:: If true, makes git convert `CRLF` at the end of lines in text files to - `LF` when reading from the filesystem, and convert in reverse when - writing to the filesystem. The variable can be set to + `LF` when reading from the work tree, and convert in reverse when + writing to the work tree. The variable can be set to 'input', in which case the conversion happens only while - reading from the filesystem but files are written out with - `LF` at the end of lines. A file is considered + reading from the work tree but files are written out to the work + tree with `LF` at the end of lines. A file is considered "text" (i.e. be subjected to the autocrlf mechanism) based on the file's `crlf` attribute, or if `crlf` is unspecified, based on the file's contents. See linkgit:gitattributes[5]. @@@ -481,8 -481,6 +481,8 @@@ core.whitespace: error (enabled by default). * `indent-with-non-tab` treats a line that is indented with 8 or more space characters as an error (not enabled by default). +* `tab-in-indent` treats a tab character in the initial indent part of + the line as an error (not enabled by default). * `blank-at-eof` treats blank lines added at the end of file as an error (enabled by default). * `trailing-space` is a short-hand to cover both `blank-at-eol` and @@@ -521,12 -519,10 +521,12 @@@ check that makes sure that existing obj core.notesRef:: When showing commit messages, also show notes which are stored in the given ref. This ref is expected to contain files named - after the full SHA-1 of the commit they annotate. + after the full SHA-1 of the commit they annotate. The ref + must be fully qualified. + If such a file exists in the given ref, the referenced blob is read, and -appended to the commit message, separated by a "Notes:" line. If the +appended to the commit message, separated by a "Notes ():" +line (shortened to "Notes:" in the case of "refs/notes/commits"). If the given ref itself does not exist, it is not an error, but means that no notes should be printed. + @@@ -694,29 -690,9 +694,29 @@@ color.grep: `never`), never. When set to `true` or `auto`, use color only when the output is written to the terminal. Defaults to `false`. -color.grep.match:: - Use customized color for matches. The value of this variable - may be specified as in color.branch.. +color.grep.:: + Use customized color for grep colorization. `` specifies which + part of the line to use the specified color, and is one of ++ +-- +`context`;; + non-matching text in context lines (when using `-A`, `-B`, or `-C`) +`filename`;; + filename prefix (when not using `-h`) +`function`;; + function name lines (when using `-p`) +`linenumber`;; + line number prefix (when using `-n`) +`match`;; + matching text +`selected`;; + non-matching text in selected lines +`separator`;; + separators between fields on a line (`:`, `-`, and `=`) + and between hunks (`--`) +-- ++ +The values of these variables may be specified as in color.branch.. color.interactive:: When set to `always`, always use colors for interactive prompts @@@ -916,7 -892,7 +916,7 @@@ format.signoff: gc.aggressiveWindow:: The window size parameter used in the delta compression algorithm used by 'git gc --aggressive'. This defaults - to 10. + to 250. gc.auto:: When there are approximately more than this many loose @@@ -1270,13 -1246,6 +1270,13 @@@ log.date: following alternatives: {relative,local,default,iso,rfc,short}. See linkgit:git-log[1]. +log.decorate:: + Print out the ref names of any commits that are shown by the log + command. If 'short' is specified, the ref name prefixes 'refs/heads/', + 'refs/tags/' and 'refs/remotes/' will not be printed. If 'full' is + specified, the full ref name (including prefix) will be printed. + This is the same as the log commands '--decorate' option. + log.showroot:: If true, the initial commit will be shown as a big creation event. This is equivalent to a diff against an empty tree. @@@ -1345,53 -1314,6 +1345,53 @@@ mergetool.keepTemporaries: mergetool.prompt:: Prompt before each invocation of the merge resolution program. +notes.displayRef:: + The (fully qualified) refname from which to show notes when + showing commit messages. The value of this variable can be set + to a glob, in which case notes from all matching refs will be + shown. You may also specify this configuration variable + several times. A warning will be issued for refs that do not + exist, but a glob that does not match any refs is silently + ignored. ++ +This setting can be overridden with the `GIT_NOTES_DISPLAY_REF` +environment variable, which must be a colon separated list of refs or +globs. ++ +The effective value of "core.notesRef" (possibly overridden by +GIT_NOTES_REF) is also implicitly added to the list of refs to be +displayed. + +notes.rewrite.:: + When rewriting commits with (currently `amend` or + `rebase`) and this variable is set to `true`, git + automatically copies your notes from the original to the + rewritten commit. Defaults to `true`, but see + "notes.rewriteRef" below. + +notes.rewriteMode:: + When copying notes during a rewrite (see the + "notes.rewrite." option), determines what to do if + the target commit already has a note. Must be one of + `overwrite`, `concatenate`, or `ignore`. Defaults to + `concatenate`. ++ +This setting can be overridden with the `GIT_NOTES_REWRITE_MODE` +environment variable. + +notes.rewriteRef:: + When copying notes during a rewrite, specifies the (fully + qualified) ref whose notes should be copied. The ref may be a + glob, in which case notes in all matching refs will be copied. + You may also specify this configuration several times. ++ +Does not have a default value; you must configure this variable to +enable note rewriting. ++ +This setting can be overridden with the `GIT_NOTES_REWRITE_REF` +environment variable, which must be a colon separated list of refs or +globs. + pack.window:: The size of the window used by linkgit:git-pack-objects[1] when no window size is given on the command line. Defaults to 10. @@@ -1531,7 -1453,7 +1531,7 @@@ receive.denyCurrentBranch: out of sync with the index and working tree. If set to "warn", print a warning of such a push to stderr, but allow the push to proceed. If set to false or "ignore", allow such pushes with no - message. Defaults to "warn". + message. Defaults to "refuse". receive.denyNonFastForwards:: If set to true, git-receive-pack will deny a ref update which is @@@ -1651,6 -1573,7 +1651,7 @@@ sendemail.smtppass: sendemail.suppresscc:: sendemail.suppressfrom:: sendemail.to:: + sendemail.smtpdomain:: sendemail.smtpserver:: sendemail.smtpserverport:: sendemail.smtpuser:: diff --combined Documentation/git-send-email.txt index 3dfdc7cca6,288a4ec303..12622fc49a --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@@ -119,6 -119,13 +119,13 @@@ Sendin value reverts to plain SMTP. Default is the value of 'sendemail.smtpencryption'. + --smtp-domain=:: + Specifies the Fully Qualified Domain Name (FQDN) used in the + HELO/EHLO command to the SMTP server. Some servers require the + FQDN to match your IP address. If not set, git send-email attempts + to determine your FQDN automatically. Default is the value of + 'sendemail.smtpdomain'. + --smtp-pass[=]:: Password for SMTP-AUTH. The argument is optional: If no argument is specified, then the empty string is used as @@@ -300,21 -307,6 +307,21 @@@ sendemail.confirm: in the previous section for the meaning of these values. +Use gmail as the smtp server +---------------------------- + +Add the following section to the config file: + + [sendemail] + smtpencryption = tls + smtpserver = smtp.gmail.com + smtpuser = yourname@gmail.com + smtpserverport = 587 + +Note: the following perl modules are required + Net::SMTP::SSL, MIME::Base64 and Authen::SASL + + Author ------ Written by Ryan Anderson diff --combined git-send-email.perl index ce569a9c8f,0f23ed380f..111c981229 --- a/git-send-email.perl +++ b/git-send-email.perl @@@ -47,9 -47,9 +47,9 @@@ git send-email [options] * Email From: - --to * Email To: - --cc * Email Cc: - --bcc * Email Bcc: + --[no-]to * Email To: + --[no-]cc * Email Cc: + --[no-]bcc * Email Bcc: --subject * Email "Subject:" --in-reply-to * Email "In-Reply-To:" --annotate * Review each patch that will be sent in an editor. @@@ -132,14 -132,12 +132,12 @@@ my $have_email_valid = eval { require E my $have_mail_address = eval { require Mail::Address; 1 }; my $smtp; my $auth; - my $mail_domain_default = "localhost.localdomain"; - my $mail_domain; sub unique_email_list(@); sub cleanup_compose_files(); # Variables we fill in automatically, or via prompting: -my (@to,@cc,@initial_cc,@bcclist,@xh, +my (@to,$no_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh, $initial_reply_to,$initial_subject,@files, $author,$sender,$smtp_authpass,$annotate,$compose,$time); @@@ -166,12 -164,9 +164,12 @@@ my $compose_filename # Handle interactive edition of files. my $multiedit; -my $editor = Git::command_oneline('var', 'GIT_EDITOR'); +my $editor; sub do_edit { + if (!defined($editor)) { + $editor = Git::command_oneline('var', 'GIT_EDITOR'); + } if (defined($multiedit) && !$multiedit) { map { system('sh', '-c', $editor.' "$@"', $editor, $_); @@@ -190,7 -185,7 +188,7 @@@ # Variables with corresponding config settings my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); - my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts); + my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts, $smtp_domain); my ($validate, $confirm); my (@suppress_cc); @@@ -212,6 -207,7 +210,7 @@@ my %config_settings = "smtpserverport" => \$smtp_server_port, "smtpuser" => \$smtp_authuser, "smtppass" => \$smtp_authpass, + "smtpdomain" => \$smtp_domain, "to" => \@to, "cc" => \@initial_cc, "cccmd" => \$cc_cmd, @@@ -270,11 -266,8 +269,11 @@@ my $rc = GetOptions("sender|from=s" => "in-reply-to=s" => \$initial_reply_to, "subject=s" => \$initial_subject, "to=s" => \@to, + "no-to" => \$no_to, "cc=s" => \@initial_cc, + "no-cc" => \$no_cc, "bcc=s" => \@bcclist, + "no-bcc" => \$no_bcc, "chain-reply-to!" => \$chain_reply_to, "smtp-server=s" => \$smtp_server, "smtp-server-port=s" => \$smtp_server_port, @@@ -283,7 -276,7 +282,7 @@@ "smtp-ssl" => sub { $smtp_encryption = 'ssl' }, "smtp-encryption=s" => \$smtp_encryption, "smtp-debug:i" => \$debug_net_smtp, - "smtp-domain:s" => \$mail_domain, + "smtp-domain:s" => \$smtp_domain, "identity=s" => \$identity, "annotate" => \$annotate, "compose" => \$compose, @@@ -319,9 -312,6 +318,9 @@@ sub read_config foreach my $setting (keys %config_settings) { my $target = $config_settings{$setting}; + next if $setting eq "to" and defined $no_to; + next if $setting eq "cc" and defined $no_cc; + next if $setting eq "bcc" and defined $no_bcc; if (ref($target) eq "ARRAY") { unless (@$target) { my @values = Git::config(@repo, "$prefix.$setting"); @@@ -761,8 -751,7 +760,7 @@@ sub extract_valid_address # We'll setup a template for the message id, using the "from" address: my ($message_id_stamp, $message_id_serial); - sub make_message_id - { + sub make_message_id { my $uniq; if (!defined $message_id_stamp) { $message_id_stamp = sprintf("%s-%s", time, $$); @@@ -817,8 -806,7 +815,7 @@@ sub is_rfc2047_quoted } # use the simplest quoting being able to handle the recipient - sub sanitize_address - { + sub sanitize_address { my ($recipient) = @_; my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/); @@@ -863,21 -851,23 +860,23 @@@ # This maildomain*() code is based on ideas in Perl library Test::Reporter # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain () - sub maildomain_net - { + sub valid_fqdn { + my $domain = shift; + return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./; + } + + sub maildomain_net { my $maildomain; if (eval { require Net::Domain; 1 }) { my $domain = Net::Domain::domainname(); - $maildomain = $domain - unless $^O eq 'darwin' && $domain =~ /\.local$/; + $maildomain = $domain if valid_fqdn($domain); } return $maildomain; } - sub maildomain_mta - { + sub maildomain_mta { my $maildomain; if (eval { require Net::SMTP; 1 }) { @@@ -887,8 -877,7 +886,7 @@@ my $domain = $smtp->domain; $smtp->quit; - $maildomain = $domain - unless $^O eq 'darwin' && $domain =~ /\.local$/; + $maildomain = $domain if valid_fqdn($domain); last if $maildomain; } @@@ -898,17 -887,15 +896,15 @@@ return $maildomain; } - sub maildomain - { - return maildomain_net() || maildomain_mta() || $mail_domain_default; + sub maildomain { + return maildomain_net() || maildomain_mta() || 'localhost.localdomain'; } # Returns 1 if the message was sent, and 0 otherwise. # In actuality, the whole program dies when there # is an error sending a message. - sub send_message - { + sub send_message { my @recipients = unique_email_list(@to); @cc = (grep { my $cc = extract_valid_address($_); not grep { $cc eq $_ } @recipients @@@ -1005,18 -992,18 +1001,18 @@@ X-Mailer: git-send-email $gitversio if ($smtp_encryption eq 'ssl') { $smtp_server_port ||= 465; # ssmtp require Net::SMTP::SSL; - $mail_domain ||= maildomain(); + $smtp_domain ||= maildomain(); $smtp ||= Net::SMTP::SSL->new($smtp_server, - Hello => $mail_domain, + Hello => $smtp_domain, Port => $smtp_server_port); } else { require Net::SMTP; - $mail_domain ||= maildomain(); + $smtp_domain ||= maildomain(); $smtp ||= Net::SMTP->new((defined $smtp_server_port) ? "$smtp_server:$smtp_server_port" : $smtp_server, - Hello => $mail_domain, + Hello => $smtp_domain, Debug => $debug_net_smtp); if ($smtp_encryption eq 'tls' && $smtp) { require Net::SMTP::SSL; @@@ -1039,7 -1026,7 +1035,7 @@@ die "Unable to initialize SMTP properly. Check config and use --smtp-debug. ", "VALUES: server=$smtp_server ", "encryption=$smtp_encryption ", - "maildomain=$mail_domain", + "hello=$smtp_domain", defined $smtp_server_port ? "port=$smtp_server_port" : ""; }