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]) .
31 my ($val) = qx{git
-repo
-config
--get merge
.summary
};
36 my ($bra) = qx{git
-symbolic
-ref HEAD
};
38 $bra =~ s
|^refs
/heads/||;
39 if ($bra ne 'master') {
50 foreach ( qx{git
-log --no-merges
--topo
-order
--pretty
=oneline
$tip ^HEAD
} ) {
54 die "git-log failed\n" if $?
;
60 my ($bname, $tname, $gname, $src, $sha1, $origin);
64 next if (/^not-for-merge/);
73 if (! exists $src{$src}) {
84 if (/^branch (.*)$/) {
86 push @
{$src{$src}{BRANCH
}}, $1;
87 $src{$src}{HEAD_STATUS
} |= 2;
89 elsif (/^tag (.*)$/) {
91 push @
{$src{$src}{TAG
}}, $1;
92 $src{$src}{HEAD_STATUS
} |= 2;
96 $src{$src}{HEAD_STATUS
} |= 1;
99 push @
{$src{$src}{GENERIC
}}, $_;
100 $src{$src}{HEAD_STATUS
} |= 2;
103 if ($src eq '.' || $src eq $origin) {
104 $origin =~ s/^'(.*)'$/$1/;
105 push @origin, [$sha1, "$origin"];
108 push @origin, [$sha1, "$origin of $src"];
114 if ($src{$src}{HEAD_STATUS
} == 1) {
115 # Only HEAD is fetched, nothing else.
120 if ($src{$src}{HEAD_STATUS
} == 3) {
121 # HEAD is fetched among others.
122 push @this, andjoin
('', '', ['HEAD']);
124 push @this, andjoin
("branch ", "branches ",
126 push @this, andjoin
("tag ", "tags ",
128 push @this, andjoin
("commit ", "commits ",
129 $src{$src}{GENERIC
});
130 my $this = join(', ', @this);
137 my $into = current_branch
();
139 print "Merge ", join("; ", @msg), $into, "\n";
145 # We limit the merge message to the latst 20 or so per each branch.
149 my ($sha1, $name) = @
$_;
150 my @log = shortlog
($sha1);
151 if ($limit + 1 <= @log) {
152 print "\n* $name: (" . scalar(@log) . " commits)\n";
155 print "\n* $name:\n";
159 if ($limit < ++$cnt) {