From: Junio C Hamano Date: Wed, 5 Aug 2009 19:37:24 +0000 (-0700) Subject: Merge branch 'maint-1.6.3' into maint X-Git-Tag: v1.6.4.1~16 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f0df1293acdba9513cae17e2c63b4169f1347371?ds=inline;hp=-c Merge branch 'maint-1.6.3' into maint * maint-1.6.3: Better usage string for reflog. hg-to-git: don't import the unused popen2 module send-email: remove debug trace config: Keep inner whitespace verbatim --- f0df1293acdba9513cae17e2c63b4169f1347371 diff --combined config.c index 738b24419d,7e5594b65e..e87edeab0c --- a/config.c +++ b/config.c @@@ -62,7 -62,8 +62,8 @@@ static char *parse_value(void if (comment) continue; if (isspace(c) && !quote) { - space = 1; + if (len) + space++; continue; } if (!quote) { @@@ -71,11 -72,8 +72,8 @@@ continue; } } - if (space) { - if (len) - value[len++] = ' '; - space = 0; - } + for (; space; space--) + value[len++] = ' '; if (c == '\\') { c = get_next_char(); switch (c) { @@@ -1174,9 -1172,7 +1172,9 @@@ write_err_out static int section_name_match (const char *buf, const char *name) { int i = 0, j = 0, dot = 0; - for (; buf[i] && buf[i] != ']'; i++) { + if (buf[i] != '[') + return 0; + for (i = 1; buf[i] && buf[i] != ']'; i++) { if (!dot && isspace(buf[i])) { dot = 1; if (name[j++] != '.') @@@ -1197,17 -1193,7 +1195,17 @@@ if (buf[i] != name[j++]) break; } - return (buf[i] == ']' && name[j] == 0); + if (buf[i] == ']' && name[j] == 0) { + /* + * We match, now just find the right length offset by + * gobbling up any whitespace after it, as well + */ + i++; + for (; buf[i] && isspace(buf[i]); i++) + ; /* do nothing */ + return i; + } + return 0; } /* if new_name == NULL, the section is removed instead */ @@@ -1237,13 -1223,11 +1235,13 @@@ int git_config_rename_section(const cha while (fgets(buf, sizeof(buf), config_file)) { int i; int length; + char *output = buf; for (i = 0; buf[i] && isspace(buf[i]); i++) ; /* do nothing */ if (buf[i] == '[') { /* it's a section */ - if (section_name_match (&buf[i+1], old_name)) { + int offset = section_name_match(&buf[i], old_name); + if (offset > 0) { ret++; if (new_name == NULL) { remove = 1; @@@ -1254,29 -1238,14 +1252,29 @@@ ret = write_error(lock->filename); goto out; } - continue; + /* + * We wrote out the new section, with + * a newline, now skip the old + * section's length + */ + output += offset + i; + if (strlen(output) > 0) { + /* + * More content means there's + * a declaration to put on the + * next line; indent with a + * tab + */ + output -= 1; + output[0] = '\t'; + } } remove = 0; } if (remove) continue; - length = strlen(buf); - if (write_in_full(out_fd, buf, length) != length) { + length = strlen(output); + if (write_in_full(out_fd, output, length) != length) { ret = write_error(lock->filename); goto out; } diff --combined git-send-email.perl index d508f83349,17f930f0f3..0700d80afc --- a/git-send-email.perl +++ b/git-send-email.perl @@@ -210,7 -210,6 +210,7 @@@ my %config_settings = "envelopesender" => \$envelope_sender, "multiedit" => \$multiedit, "confirm" => \$confirm, + "from" => \$sender, ); # Handle Uncouth Termination @@@ -334,7 -333,7 +334,7 @@@ if (@suppress_cc) } if ($suppress_cc{'all'}) { - foreach my $entry (qw (ccmd cc author self sob body bodycc)) { + foreach my $entry (qw (cccmd cc author self sob body bodycc)) { $suppress_cc{$entry} = 1; } delete $suppress_cc{'all'}; @@@ -410,7 -409,7 +410,7 @@@ my %parse_alias = mailrc => sub { my $fh = shift; while (<$fh>) { if (/^alias\s+(\S+)\s+(.*)$/) { # spaces delimit multiple addresses - $aliases{$1} = [ split(/\s+/, $2) ]; + $aliases{$1} = [ quotewords('\s+', 0, $2) ]; }}}, pine => sub { my $fh = shift; my $f='\t[^\t]*'; for (my $x = ''; defined($x); $x = $_) { @@@ -450,7 -449,6 +450,6 @@@ sub check_file_rev_conflict($) try { $repo->command('rev-parse', '--verify', '--quiet', $f); if (defined($format_patch)) { - print "foo\n"; return $format_patch; } die(<) { - next if m/^GIT: /; + next if m/^GIT:/; if ($in_body) { $summary_empty = 0 unless (/^\n$/); } elsif (/^\n$/) { @@@ -577,7 -577,7 +576,7 @@@ if ($need_8bit_cte) { print C2 "MIME-Version: 1.0\n", "Content-Type: text/plain; ", - "charset=utf-8\n", + "charset=UTF-8\n", "Content-Transfer-Encoding: 8bit\n"; } } elsif (/^MIME-Version:/i) { @@@ -654,17 -654,13 +653,17 @@@ if (!@to) } sub expand_aliases { - my @cur = @_; - my @last; - do { - @last = @cur; - @cur = map { $aliases{$_} ? @{$aliases{$_}} : $_ } @last; - } while (join(',',@cur) ne join(',',@last)); - return @cur; + return map { expand_one_alias($_) } @_; +} + +my %EXPANDED_ALIASES; +sub expand_one_alias { + my $alias = shift; + if ($EXPANDED_ALIASES{$alias}) { + die "fatal: alias '$alias' expands to itself\n"; + } + local $EXPANDED_ALIASES{$alias} = 1; + return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias; } @to = expand_aliases(@to); @@@ -770,20 -766,12 +769,20 @@@ sub unquote_rfc2047 sub quote_rfc2047 { local $_ = shift; - my $encoding = shift || 'utf-8'; + my $encoding = shift || 'UTF-8'; s/([^-a-zA-Z0-9!*+\/])/sprintf("=%02X", ord($1))/eg; s/(.*)/=\?$encoding\?q\?$1\?=/; return $_; } +sub is_rfc2047_quoted { + my $s = shift; + my $token = '[^][()<>@,;:"\/?.= \000-\037\177-\377]+'; + my $encoded_text = '[!->@-~]+'; + length($s) <= 75 && + $s =~ m/^(?:"[[:ascii:]]*"|=\?$token\?$token\?$encoded_text\?=)$/o; +} + # use the simplest quoting being able to handle the recipient sub sanitize_address { @@@ -795,7 -783,7 +794,7 @@@ } # if recipient_name is already quoted, do nothing - if ($recipient_name =~ /^("[[:ascii:]]*"|=\?utf-8\?q\?.*\?=)$/) { + if (is_rfc2047_quoted($recipient_name)) { return $recipient; } @@@ -815,10 -803,6 +814,10 @@@ } +# 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 { my @recipients = unique_email_list(@to); @@@ -887,7 -871,7 +886,7 @@@ X-Mailer: git-send-email $gitversio default => $ask_default); die "Send this email reply required" unless defined $_; if (/^n/i) { - return; + return 0; } elsif (/^q/i) { cleanup_compose_files(); exit(0); @@@ -968,7 -952,7 +967,7 @@@ $smtp->data or die $smtp->message; $smtp->datasend("$header\n$message") or die $smtp->message; $smtp->dataend() or die $smtp->message; - $smtp->ok or die "Failed to send $subject\n".$smtp->message; + $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message; } if ($quiet) { printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); @@@ -989,8 -973,6 +988,8 @@@ print "Result: OK\n"; } } + + return 1; } $reply_to = $initial_reply_to; @@@ -1108,7 -1090,7 +1107,7 @@@ foreach my $t (@files) close F; if (defined $cc_cmd && !$suppress_cc{'cccmd'}) { - open(F, "$cc_cmd $t |") + open(F, "$cc_cmd \Q$t\E |") or die "(cc-cmd) Could not execute '$cc_cmd'"; while() { my $c = $_; @@@ -1151,11 -1133,10 +1150,11 @@@ @cc = (@initial_cc, @cc); - send_message(); + my $message_was_sent = send_message(); # set up for the next message - if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) { + if ($thread && $message_was_sent && + ($chain_reply_to || !defined $reply_to || length($reply_to) == 0)) { $reply_to = $message_id; if (length $references > 0) { $references .= "\n $message_id"; diff --combined t/t1300-repo-config.sh index 8c43dcde8a,91cbd551d8..83b7294010 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@@ -459,28 -459,6 +459,28 @@@ EO test_expect_success "rename succeeded" "test_cmp expect .git/config" +cat >> .git/config << EOF +[branch "vier"] z = 1 +EOF + +test_expect_success "rename a section with a var on the same line" \ + 'git config --rename-section branch.vier branch.zwei' + +cat > expect << EOF +# Hallo + #Bello +[branch "zwei"] + x = 1 +[branch "zwei"] + y = 1 +[branch "drei"] +weird +[branch "zwei"] + z = 1 +EOF + +test_expect_success "rename succeeded" "test_cmp expect .git/config" + cat >> .git/config << EOF [branch "zwei"] a = 1 [branch "vier"] EOF @@@ -755,6 -733,11 +755,11 @@@ echo >>resul test_expect_success '--null --get-regexp' 'cmp result expect' + test_expect_success 'inner whitespace kept verbatim' ' + git config section.val "foo bar" && + test "z$(git config section.val)" = "zfoo bar" + ' + test_expect_success SYMLINKS 'symlinked configuration' ' ln -s notyet myconfig &&