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.
11 my $repo = Git
->repository();
16 my ($label, $labels, $stuff) = @_;
17 my $l = scalar @
$stuff;
23 $m = "$label$stuff->[0]";
27 join (', ', @
{$stuff}[0..$l-2]) .
34 my ($val) = $repo->command_oneline('repo-config', '--get', 'merge.summary');
39 my ($bra) = $repo->command_oneline('symbolic-ref', 'HEAD');
40 $bra =~ s
|^refs
/heads/||;
41 if ($bra ne 'master') {
52 foreach ($repo->command('log', '--no-merges', '--topo-order', '--pretty=oneline', $tip, '^HEAD')) {
61 my ($bname, $tname, $gname, $src, $sha1, $origin);
65 next if (/^not-for-merge/);
74 if (! exists $src{$src}) {
86 if (/^branch (.*)$/) {
88 push @
{$src{$src}{BRANCH
}}, $1;
89 $src{$src}{HEAD_STATUS
} |= 2;
91 elsif (/^tag (.*)$/) {
93 push @
{$src{$src}{TAG
}}, $1;
94 $src{$src}{HEAD_STATUS
} |= 2;
96 elsif (/^remote branch (.*)$/) {
98 push @
{$src{$src}{R_BRANCH
}}, $1;
99 $src{$src}{HEAD_STATUS
} |= 2;
103 $src{$src}{HEAD_STATUS
} |= 1;
106 push @
{$src{$src}{GENERIC
}}, $_;
107 $src{$src}{HEAD_STATUS
} |= 2;
110 if ($src eq '.' || $src eq $origin) {
111 $origin =~ s/^'(.*)'$/$1/;
112 push @origin, [$sha1, "$origin"];
115 push @origin, [$sha1, "$origin of $src"];
121 if ($src{$src}{HEAD_STATUS
} == 1) {
122 # Only HEAD is fetched, nothing else.
127 if ($src{$src}{HEAD_STATUS
} == 3) {
128 # HEAD is fetched among others.
129 push @this, andjoin
('', '', ['HEAD']);
131 push @this, andjoin
("branch ", "branches ",
133 push @this, andjoin
("remote branch ", "remote branches ",
134 $src{$src}{R_BRANCH
});
135 push @this, andjoin
("tag ", "tags ",
137 push @this, andjoin
("commit ", "commits ",
138 $src{$src}{GENERIC
});
139 my $this = join(', ', @this);
146 my $into = current_branch
();
148 print "Merge ", join("; ", @msg), $into, "\n";
154 # We limit the merge message to the latst 20 or so per each branch.
158 my ($sha1, $name) = @
$_;
159 my @log = shortlog
($sha1);
160 if ($limit + 1 <= @log) {
161 print "\n* $name: (" . scalar(@log) . " commits)\n";
164 print "\n* $name:\n";
168 if ($limit < ++$cnt) {