Merge branch 'jc/merge-msg'

* jc/merge-msg:
  fmt-merge-msg: do not add excess newline at the end.
  fmt-merge-msg: say which branch things were merged into unless 'master'
This commit is contained in:
Junio C Hamano 2006-02-19 21:18:17 -08:00
commit 73be17f0b3

View File

@ -39,20 +39,26 @@ sub repoconfig {
return $val; return $val;
} }
sub mergebase { sub current_branch {
my ($other) = @_;
my $fh; my $fh;
open $fh, '-|', 'git-merge-base', '--all', 'HEAD', $other or die "$!"; open $fh, '-|', 'git-symbolic-ref', 'HEAD' or die "$!";
my (@mb) = map { chomp; $_ } <$fh>; my ($bra) = <$fh>;
close $fh or die "$!"; chomp($bra);
return @mb; $bra =~ s|^refs/heads/||;
if ($bra ne 'master') {
$bra = " into $bra";
} else {
$bra = "";
}
return $bra;
} }
sub shortlog { sub shortlog {
my ($tip, $limit, @base) = @_; my ($tip, $limit) = @_;
my ($fh, @result); my ($fh, @result);
open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order', open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order',
'--pretty=oneline', $tip, map { "^$_" } @base) '--pretty=oneline', $tip, '^HEAD')
or die "$!"; or die "$!";
while (<$fh>) { while (<$fh>) {
s/^[0-9a-f]{40}\s+//; s/^[0-9a-f]{40}\s+//;
@ -140,7 +146,10 @@ for my $src (@src) {
} }
push @msg, $this; push @msg, $this;
} }
print "Merge ", join("; ", @msg), "\n";
my $into = current_branch();
print "Merge ", join("; ", @msg), $into, "\n";
if (!repoconfig) { if (!repoconfig) {
exit(0); exit(0);
@ -151,8 +160,7 @@ my $limit = 20;
for (@origin) { for (@origin) {
my ($sha1, $name) = @$_; my ($sha1, $name) = @$_;
my @mb = mergebase($sha1); my @log = shortlog($sha1, $limit + 1);
my @log = shortlog($sha1, $limit + 1, @mb);
if ($limit + 1 <= @log) { if ($limit + 1 <= @log) {
print "\n* $name: (" . scalar(@log) . " commits)\n"; print "\n* $name: (" . scalar(@log) . " commits)\n";
} }