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]) .
33 my $pid = open(my $fh, '-|');
35 exec('git-repo-config', '--get', 'merge.summary');
45 my $pid = open($fh, '-|');
46 die "$!" unless defined $pid;
48 exec('git-symbolic-ref', 'HEAD') or die "$!";
52 close $fh or die "$!";
53 $bra =~ s
|^refs
/heads/||;
54 if ($bra ne 'master') {
65 my $pid = open($fh, '-|');
66 die "$!" unless defined $pid;
68 exec('git-log', '--topo-order',
69 '--pretty=oneline', $tip, '^HEAD') or die "$!";
75 close $fh or die "$!";
81 my ($bname, $tname, $gname, $src, $sha1, $origin);
85 next if (/^not-for-merge/);
94 if (! exists $src{$src}) {
105 if (/^branch (.*)$/) {
107 push @
{$src{$src}{BRANCH
}}, $1;
108 $src{$src}{HEAD_STATUS
} |= 2;
110 elsif (/^tag (.*)$/) {
112 push @
{$src{$src}{TAG
}}, $1;
113 $src{$src}{HEAD_STATUS
} |= 2;
117 $src{$src}{HEAD_STATUS
} |= 1;
120 push @
{$src{$src}{GENERIC
}}, $_;
121 $src{$src}{HEAD_STATUS
} |= 2;
124 if ($src eq '.' || $src eq $origin) {
125 $origin =~ s/^'(.*)'$/$1/;
126 push @origin, [$sha1, "$origin"];
129 push @origin, [$sha1, "$origin of $src"];
135 if ($src{$src}{HEAD_STATUS
} == 1) {
136 # Only HEAD is fetched, nothing else.
141 if ($src{$src}{HEAD_STATUS
} == 3) {
142 # HEAD is fetched among others.
143 push @this, andjoin
('', '', ['HEAD']);
145 push @this, andjoin
("branch ", "branches ",
147 push @this, andjoin
("tag ", "tags ",
149 push @this, andjoin
("commit ", "commits ",
150 $src{$src}{GENERIC
});
151 my $this = join(', ', @this);
158 my $into = current_branch
();
160 print "Merge ", join("; ", @msg), $into, "\n";
166 # We limit the merge message to the latst 20 or so per each branch.
170 my ($sha1, $name) = @
$_;
171 my @log = shortlog
($sha1);
172 if ($limit + 1 <= @log) {
173 print "\n* $name: (" . scalar(@log) . " commits)\n";
176 print "\n* $name:\n";
180 if ($limit < ++$cnt) {