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 "$!";
46 $bra =~ s|^refs/heads/||;
47 if ($bra ne 'master') {
57 my ($tip, $limit) = @_;
59 open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order',
60 '--pretty=oneline', $tip, '^HEAD')
66 close $fh or die "$!";
72 my ($bname, $tname, $gname, $src, $sha1, $origin);
76 next if (/^not-for-merge/);
85 if (! exists $src{$src}) {
96 if (/^branch (.*)$/) {
98 push @{$src{$src}{BRANCH}}, $1;
99 $src{$src}{HEAD_STATUS} |= 2;
101 elsif (/^tag (.*)$/) {
103 push @{$src{$src}{TAG}}, $1;
104 $src{$src}{HEAD_STATUS} |= 2;
108 $src{$src}{HEAD_STATUS} |= 1;
111 push @{$src{$src}{GENERIC}}, $_;
112 $src{$src}{HEAD_STATUS} |= 2;
115 if ($src eq '.' || $src eq $origin) {
116 $origin =~ s/^'(.*)'$/$1/;
117 push @origin, [$sha1, "$origin"];
120 push @origin, [$sha1, "$origin of $src"];
126 if ($src{$src}{HEAD_STATUS} == 1) {
127 # Only HEAD is fetched, nothing else.
132 if ($src{$src}{HEAD_STATUS} == 3) {
133 # HEAD is fetched among others.
134 push @this, andjoin('', '', ['HEAD']);
136 push @this, andjoin("branch ", "branches ",
138 push @this, andjoin("tag ", "tags ",
140 push @this, andjoin("commit ", "commits ",
141 $src{$src}{GENERIC});
142 my $this = join(', ', @this);
149 my $into = current_branch();
151 print "Merge ", join("; ", @msg), $into, "\n";
157 # We limit the merge message to the latst 20 or so per each branch.
161 my ($sha1, $name) = @$_;
162 my @log = shortlog($sha1, $limit + 1);
163 if ($limit + 1 <= @log) {
164 print "\n* $name: (" . scalar(@log) . " commits)\n";
167 print "\n* $name:\n";
171 if ($limit < ++$cnt) {