3 # Copyright (c) 2005 Junio C Hamano
5 # Read .git/FETCH_HEAD and make a human readable merge message
6 # by grouping branches and tags together to form a single line.
13 my ($label, $labels, $stuff) = @_;
14 my $l = scalar @$stuff;
20 $m = "$label$stuff->[0]";
24 join (', ', @{$stuff}[0..$l-2]) .
34 open $fh, '-|', 'git-repo-config', '--get', 'merge.summary'
44 open $fh, '-|', 'git-symbolic-ref', 'HEAD' or die "$!";
47 $bra =~ s|^refs/heads/||;
48 if ($bra ne 'master') {
60 open $fh, '-|', ('git-log', '--topo-order',
61 '--pretty=oneline', $tip, '^HEAD')
67 close $fh or die "$!";
73 my ($bname, $tname, $gname, $src, $sha1, $origin);
77 next if (/^not-for-merge/);
86 if (! exists $src{$src}) {
97 if (/^branch (.*)$/) {
99 push @{$src{$src}{BRANCH}}, $1;
100 $src{$src}{HEAD_STATUS} |= 2;
102 elsif (/^tag (.*)$/) {
104 push @{$src{$src}{TAG}}, $1;
105 $src{$src}{HEAD_STATUS} |= 2;
109 $src{$src}{HEAD_STATUS} |= 1;
112 push @{$src{$src}{GENERIC}}, $_;
113 $src{$src}{HEAD_STATUS} |= 2;
116 if ($src eq '.' || $src eq $origin) {
117 $origin =~ s/^'(.*)'$/$1/;
118 push @origin, [$sha1, "$origin"];
121 push @origin, [$sha1, "$origin of $src"];
127 if ($src{$src}{HEAD_STATUS} == 1) {
128 # Only HEAD is fetched, nothing else.
133 if ($src{$src}{HEAD_STATUS} == 3) {
134 # HEAD is fetched among others.
135 push @this, andjoin('', '', ['HEAD']);
137 push @this, andjoin("branch ", "branches ",
139 push @this, andjoin("tag ", "tags ",
141 push @this, andjoin("commit ", "commits ",
142 $src{$src}{GENERIC});
143 my $this = join(', ', @this);
150 my $into = current_branch();
152 print "Merge ", join("; ", @msg), $into, "\n";
158 # We limit the merge message to the latst 20 or so per each branch.
162 my ($sha1, $name) = @$_;
163 my @log = shortlog($sha1);
164 if ($limit + 1 <= @log) {
165 print "\n* $name: (" . scalar(@log) . " commits)\n";
168 print "\n* $name:\n";
172 if ($limit < ++$cnt) {