summaryrefslogtreecommitdiff
path: root/git-fmt-merge-msg.perl
diff options
context:
space:
mode:
Diffstat (limited to 'git-fmt-merge-msg.perl')
-rwxr-xr-xgit-fmt-merge-msg.perl46
1 files changed, 31 insertions, 15 deletions
diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl
index 0467a387e1..c13af4884a 100755
--- a/git-fmt-merge-msg.perl
+++ b/git-fmt-merge-msg.perl
@@ -28,32 +28,46 @@ sub andjoin {
}
sub repoconfig {
- my $fh;
my $val;
eval {
- open $fh, '-|', 'git-repo-config', '--get', 'merge.summary'
- or die "$!";
+ my $pid = open(my $fh, '-|');
+ if (!$pid) {
+ exec('git-repo-config', '--get', 'merge.summary');
+ }
($val) = <$fh>;
close $fh;
};
return $val;
}
-sub mergebase {
- my ($other) = @_;
+sub current_branch {
my $fh;
- open $fh, '-|', 'git-merge-base', '--all', 'HEAD', $other or die "$!";
- my (@mb) = map { chomp; $_ } <$fh>;
+ my $pid = open($fh, '-|');
+ die "$!" unless defined $pid;
+ if (!$pid) {
+ exec('git-symbolic-ref', 'HEAD') or die "$!";
+ }
+ my ($bra) = <$fh>;
+ chomp($bra);
close $fh or die "$!";
- return @mb;
+ $bra =~ s|^refs/heads/||;
+ if ($bra ne 'master') {
+ $bra = " into $bra";
+ } else {
+ $bra = "";
+ }
+ return $bra;
}
sub shortlog {
- my ($tip, $limit, @base) = @_;
+ my ($tip) = @_;
my ($fh, @result);
- open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order',
- '--pretty=oneline', $tip, map { "^$_" } @base)
- or die "$!";
+ my $pid = open($fh, '-|');
+ die "$!" unless defined $pid;
+ if (!$pid) {
+ exec('git-log', '--topo-order',
+ '--pretty=oneline', $tip, '^HEAD') or die "$!";
+ }
while (<$fh>) {
s/^[0-9a-f]{40}\s+//;
push @result, $_;
@@ -140,7 +154,10 @@ for my $src (@src) {
}
push @msg, $this;
}
-print "Merge ", join("; ", @msg), "\n";
+
+my $into = current_branch();
+
+print "Merge ", join("; ", @msg), $into, "\n";
if (!repoconfig) {
exit(0);
@@ -151,8 +168,7 @@ my $limit = 20;
for (@origin) {
my ($sha1, $name) = @$_;
- my @mb = mergebase($sha1);
- my @log = shortlog($sha1, $limit + 1, @mb);
+ my @log = shortlog($sha1);
if ($limit + 1 <= @log) {
print "\n* $name: (" . scalar(@log) . " commits)\n";
}