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.
12 my $repo = Git
->repository();
17 my ($label, $labels, $stuff) = @_;
18 my $l = scalar @
$stuff;
24 $m = "$label$stuff->[0]";
28 join (', ', @
{$stuff}[0..$l-2]) .
37 $val = $repo->command_oneline('repo-config', '--get', 'merge.summary');
38 } catch Git
::Error
::Command with
{
40 if ($E->value() == 1) {
50 my ($bra) = $repo->command_oneline('symbolic-ref', 'HEAD');
51 $bra =~ s
|^refs
/heads/||;
52 if ($bra ne 'master') {
63 foreach ($repo->command('log', '--no-merges', '--topo-order', '--pretty=oneline', $tip, '^HEAD')) {
72 my ($bname, $tname, $gname, $src, $sha1, $origin);
76 next if (/^not-for-merge/);
85 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;
107 elsif (/^remote branch (.*)$/) {
109 push @
{$src{$src}{R_BRANCH
}}, $1;
110 $src{$src}{HEAD_STATUS
} |= 2;
114 $src{$src}{HEAD_STATUS
} |= 1;
117 push @
{$src{$src}{GENERIC
}}, $_;
118 $src{$src}{HEAD_STATUS
} |= 2;
121 if ($src eq '.' || $src eq $origin) {
122 $origin =~ s/^'(.*)'$/$1/;
123 push @origin, [$sha1, "$origin"];
126 push @origin, [$sha1, "$origin of $src"];
132 if ($src{$src}{HEAD_STATUS
} == 1) {
133 # Only HEAD is fetched, nothing else.
138 if ($src{$src}{HEAD_STATUS
} == 3) {
139 # HEAD is fetched among others.
140 push @this, andjoin
('', '', ['HEAD']);
142 push @this, andjoin
("branch ", "branches ",
144 push @this, andjoin
("remote branch ", "remote branches ",
145 $src{$src}{R_BRANCH
});
146 push @this, andjoin
("tag ", "tags ",
148 push @this, andjoin
("commit ", "commits ",
149 $src{$src}{GENERIC
});
150 my $this = join(', ', @this);
157 my $into = current_branch
();
159 print "Merge ", join("; ", @msg), $into, "\n";
165 # We limit the merge message to the latst 20 or so per each branch.
169 my ($sha1, $name) = @
$_;
170 my @log = shortlog
($sha1);
171 if ($limit + 1 <= @log) {
172 print "\n* $name: (" . scalar(@log) . " commits)\n";
175 print "\n* $name:\n";
179 if ($limit < ++$cnt) {