@matheusbsbs / matheus-bagliano / commits / 2b020455f9
Fork 0

fmt-merge-msg: say which branch things were merged into unless 'master'

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 18, 2006 at 22:37 UTC 2b020455f92ea3c20a78005dd19e7a127bb5b481
1 file changed +18 -11
git-fmt-merge-msg.perl
+18 -11
@@ -39,20 +39,25 @@ sub repoconfig {
39 return $val;
40 }
41
42 -sub mergebase {
43 - my ($other) = @_;
42 +sub current_branch {
43 my $fh;
45 - open $fh, '-|', 'git-merge-base', '--all', 'HEAD', $other or die "$!";
46 - my (@mb) = map { chomp; $_ } <$fh>;
47 - close $fh or die "$!";
48 - return @mb;
44 + open $fh, '-|', 'git-symbolic-ref', 'HEAD' or die "$!";
45 + my ($bra) = <$fh>;
46 + $bra =~ s|^refs/heads/||;
47 + if ($bra ne 'master') {
48 + $bra = " into $bra";
49 + } else {
50 + $bra = "";
51 + }
52 +
53 + return $bra;
54 }
55
56 sub shortlog {
52 - my ($tip, $limit, @base) = @_;
57 + my ($tip, $limit) = @_;
58 my ($fh, @result);
59 open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order',
55 - '--pretty=oneline', $tip, map { "^$_" } @base)
60 + '--pretty=oneline', $tip, '^HEAD')
61 or die "$!";
62 while (<$fh>) {
63 s/^[0-9a-f]{40}\s+//;
@@ -140,7 +145,10 @@ for my $src (@src) {
145 }
146 push @msg, $this;
147 }
143 -print "Merge ", join("; ", @msg), "\n";
148 +
149 +my $into = current_branch();
150 +
151 +print "Merge ", join("; ", @msg), $into, "\n";
152
153 if (!repoconfig) {
154 exit(0);
@@ -151,8 +159,7 @@ my $limit = 20;
159
160 for (@origin) {
161 my ($sha1, $name) = @$_;
154 - my @mb = mergebase($sha1);
155 - my @log = shortlog($sha1, $limit + 1, @mb);
162 + my @log = shortlog($sha1, $limit + 1);
163 if ($limit + 1 <= @log) {
164 print "\n* $name: (" . scalar(@log) . " commits)\n";
165 }